[multiple changes]
[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
30 @settitle GNAT Reference Manual
31
32 @setchapternewpage odd
33 @syncodeindex fn cp
34
35 @include gcc-common.texi
36
37 @dircategory GNU Ada tools
38 @direntry
39 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
40 @end direntry
41
42 @titlepage
43 @title GNAT Reference Manual
44 @subtitle GNAT, The GNU Ada Development Environment
45 @versionsubtitle
46 @author AdaCore
47 @page
48 @vskip 0pt plus 1filll
49
50 @insertcopying
51
52 @end titlepage
53
54 @ifnottex
55 @node Top, About This Guide, (dir), (dir)
56 @top GNAT Reference Manual
57
58 @noindent
59 GNAT Reference Manual
60
61 @noindent
62 GNAT, The GNU Ada Development Environment@*
63 GCC version @value{version-GCC}@*
64
65 @noindent
66 AdaCore
67
68 @menu
69 * About This Guide::
70 * Implementation Defined Pragmas::
71 * Implementation Defined Aspects::
72 * Implementation Defined Attributes::
73 * Standard and Implementation Defined Restrictions::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
80 * The GNAT Library::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Implementation of Ada 2012 Features::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
87 * Index::
88
89 --- The Detailed Node Listing ---
90
91 About This Guide
92
93 * What This Reference Manual Contains::
94 * Related Information::
95
96 Implementation Defined Pragmas
97
98 * Pragma Abort_Defer::
99 * Pragma Abstract_State::
100 * Pragma Ada_83::
101 * Pragma Ada_95::
102 * Pragma Ada_05::
103 * Pragma Ada_2005::
104 * Pragma Ada_12::
105 * Pragma Ada_2012::
106 * Pragma Allow_Integer_Address::
107 * Pragma Annotate::
108 * Pragma Assert::
109 * Pragma Assert_And_Cut::
110 * Pragma Assertion_Policy::
111 * Pragma Assume::
112 * Pragma Assume_No_Invalid_Values::
113 * Pragma Async_Readers::
114 * Pragma Async_Writers::
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 Compiler_Unit_Warning::
129 * Pragma Complete_Representation::
130 * Pragma Complex_Representation::
131 * Pragma Component_Alignment::
132 * Pragma Contract_Cases::
133 * Pragma Convention_Identifier::
134 * Pragma CPP_Class::
135 * Pragma CPP_Constructor::
136 * Pragma CPP_Virtual::
137 * Pragma CPP_Vtable::
138 * Pragma CPU::
139 * Pragma Debug::
140 * Pragma Debug_Policy::
141 * Pragma Default_Storage_Pool::
142 * Pragma Depends::
143 * Pragma Detect_Blocking::
144 * Pragma Disable_Atomic_Synchronization::
145 * Pragma Dispatching_Domain::
146 * Pragma Effective_Reads::
147 * Pragma Effective_Writes::
148 * Pragma Elaboration_Checks::
149 * Pragma Eliminate::
150 * Pragma Enable_Atomic_Synchronization::
151 * Pragma Export_Exception::
152 * Pragma Export_Function::
153 * Pragma Export_Object::
154 * Pragma Export_Procedure::
155 * Pragma Export_Value::
156 * Pragma Export_Valued_Procedure::
157 * Pragma Extend_System::
158 * Pragma Extensions_Allowed::
159 * Pragma External::
160 * Pragma External_Name_Casing::
161 * Pragma Fast_Math::
162 * Pragma Favor_Top_Level::
163 * Pragma Finalize_Storage_Only::
164 * Pragma Float_Representation::
165 * Pragma Global::
166 * Pragma Ident::
167 * Pragma Implementation_Defined::
168 * Pragma Implemented::
169 * Pragma Implicit_Packing::
170 * Pragma Import_Exception::
171 * Pragma Import_Function::
172 * Pragma Import_Object::
173 * Pragma Import_Procedure::
174 * Pragma Import_Valued_Procedure::
175 * Pragma Independent::
176 * Pragma Independent_Components::
177 * Pragma Initial_Condition::
178 * Pragma Initialize_Scalars::
179 * Pragma Initializes::
180 * Pragma Inline_Always::
181 * Pragma Inline_Generic::
182 * Pragma Interface::
183 * Pragma Interface_Name::
184 * Pragma Interrupt_Handler::
185 * Pragma Interrupt_State::
186 * Pragma Invariant::
187 * Pragma Java_Constructor::
188 * Pragma Java_Interface::
189 * Pragma Keep_Names::
190 * Pragma License::
191 * Pragma Link_With::
192 * Pragma Linker_Alias::
193 * Pragma Linker_Constructor::
194 * Pragma Linker_Destructor::
195 * Pragma Linker_Section::
196 * Pragma Long_Float::
197 * Pragma Loop_Invariant::
198 * Pragma Loop_Optimize::
199 * Pragma Loop_Variant::
200 * Pragma Machine_Attribute::
201 * Pragma Main::
202 * Pragma Main_Storage::
203 * Pragma No_Body::
204 * Pragma No_Inline::
205 * Pragma No_Return::
206 * Pragma No_Run_Time::
207 * Pragma No_Strict_Aliasing ::
208 * Pragma Normalize_Scalars::
209 * Pragma Obsolescent::
210 * Pragma Optimize_Alignment::
211 * Pragma Ordered::
212 * Pragma Overflow_Mode::
213 * Pragma Overriding_Renamings::
214 * Pragma Partition_Elaboration_Policy::
215 * Pragma Part_Of::
216 * Pragma Passive::
217 * Pragma Persistent_BSS::
218 * Pragma Polling::
219 * Pragma Post::
220 * Pragma Postcondition::
221 * Pragma Post_Class::
222 * Pragma Pre::
223 * Pragma Precondition::
224 * Pragma Predicate::
225 * Pragma Preelaborable_Initialization::
226 * Pragma Pre_Class::
227 * Pragma Priority_Specific_Dispatching::
228 * Pragma Profile::
229 * Pragma Profile_Warnings::
230 * Pragma Propagate_Exceptions::
231 * Pragma Provide_Shift_Operators::
232 * Pragma Psect_Object::
233 * Pragma Pure_Function::
234 * Pragma Ravenscar::
235 * Pragma Refined_Depends::
236 * Pragma Refined_Global::
237 * Pragma Refined_Post::
238 * Pragma Refined_State::
239 * Pragma Relative_Deadline::
240 * Pragma Remote_Access_Type::
241 * Pragma Restricted_Run_Time::
242 * Pragma Restriction_Warnings::
243 * Pragma Reviewable::
244 * Pragma Share_Generic::
245 * Pragma Shared::
246 * Pragma Short_Circuit_And_Or::
247 * Pragma Short_Descriptors::
248 * Pragma Simple_Storage_Pool_Type::
249 * Pragma Source_File_Name::
250 * Pragma Source_File_Name_Project::
251 * Pragma Source_Reference::
252 * Pragma SPARK_Mode::
253 * Pragma Static_Elaboration_Desired::
254 * Pragma Stream_Convert::
255 * Pragma Style_Checks::
256 * Pragma Subtitle::
257 * Pragma Suppress::
258 * Pragma Suppress_All::
259 * Pragma Suppress_Debug_Info::
260 * Pragma Suppress_Exception_Locations::
261 * Pragma Suppress_Initialization::
262 * Pragma Task_Name::
263 * Pragma Task_Storage::
264 * Pragma Test_Case::
265 * Pragma Thread_Local_Storage::
266 * Pragma Time_Slice::
267 * Pragma Title::
268 * Pragma Type_Invariant::
269 * Pragma Type_Invariant_Class::
270 * Pragma Unchecked_Union::
271 * Pragma Unimplemented_Unit::
272 * Pragma Universal_Aliasing ::
273 * Pragma Universal_Data::
274 * Pragma Unmodified::
275 * Pragma Unreferenced::
276 * Pragma Unreferenced_Objects::
277 * Pragma Unreserve_All_Interrupts::
278 * Pragma Unsuppress::
279 * Pragma Use_VADS_Size::
280 * Pragma Validity_Checks::
281 * Pragma Volatile::
282 * Pragma Warning_As_Error::
283 * Pragma Warnings::
284 * Pragma Weak_External::
285 * Pragma Wide_Character_Encoding::
286
287 Implementation Defined Aspects
288
289 * Aspect Abstract_State::
290 * Aspect Async_Readers::
291 * Aspect Async_Writers::
292 * Aspect Contract_Cases::
293 * Aspect Depends::
294 * Aspect Dimension::
295 * Aspect Dimension_System::
296 * Aspect Effective_Reads::
297 * Aspect Effective_Writes::
298 * Aspect Favor_Top_Level::
299 * Aspect Global::
300 * Aspect Initial_Condition::
301 * Aspect Initializes::
302 * Aspect Inline_Always::
303 * Aspect Invariant::
304 * Aspect Linker_Section::
305 * Aspect Object_Size::
306 * Aspect Part_Of::
307 * Aspect Persistent_BSS::
308 * Aspect Predicate::
309 * Aspect Pure_Function::
310 * Aspect Refined_Depends::
311 * Aspect Refined_Global::
312 * Aspect Refined_Post::
313 * Aspect Refined_State::
314 * Aspect Remote_Access_Type::
315 * Aspect Scalar_Storage_Order::
316 * Aspect Shared::
317 * Aspect Simple_Storage_Pool::
318 * Aspect Simple_Storage_Pool_Type::
319 * Aspect SPARK_Mode::
320 * Aspect Suppress_Debug_Info::
321 * Aspect Test_Case::
322 * Aspect Thread_Local_Storage::
323 * Aspect Universal_Aliasing::
324 * Aspect Universal_Data::
325 * Aspect Unmodified::
326 * Aspect Unreferenced::
327 * Aspect Unreferenced_Objects::
328 * Aspect Value_Size::
329 * Aspect Warnings::
330
331 Implementation Defined Attributes
332
333 * Attribute Abort_Signal::
334 * Attribute Address_Size::
335 * Attribute Asm_Input::
336 * Attribute Asm_Output::
337 * Attribute AST_Entry::
338 * Attribute Bit::
339 * Attribute Bit_Position::
340 * Attribute Compiler_Version::
341 * Attribute Code_Address::
342 * Attribute Default_Bit_Order::
343 * Attribute Descriptor_Size::
344 * Attribute Elaborated::
345 * Attribute Elab_Body::
346 * Attribute Elab_Spec::
347 * Attribute Elab_Subp_Body::
348 * Attribute Emax::
349 * Attribute Enabled::
350 * Attribute Enum_Rep::
351 * Attribute Enum_Val::
352 * Attribute Epsilon::
353 * Attribute Fixed_Value::
354 * Attribute Has_Access_Values::
355 * Attribute Has_Discriminants::
356 * Attribute Img::
357 * Attribute Integer_Value::
358 * Attribute Invalid_Value::
359 * Attribute Large::
360 * Attribute Library_Level::
361 * Attribute Loop_Entry::
362 * Attribute Machine_Size::
363 * Attribute Mantissa::
364 * Attribute Max_Interrupt_Priority::
365 * Attribute Max_Priority::
366 * Attribute Maximum_Alignment::
367 * Attribute Mechanism_Code::
368 * Attribute Null_Parameter::
369 * Attribute Object_Size::
370 * Attribute Passed_By_Reference::
371 * Attribute Pool_Address::
372 * Attribute Range_Length::
373 * Attribute Ref::
374 * Attribute Restriction_Set::
375 * Attribute Result::
376 * Attribute Safe_Emax::
377 * Attribute Safe_Large::
378 * Attribute Scalar_Storage_Order::
379 * Attribute Simple_Storage_Pool::
380 * Attribute Small::
381 * Attribute Storage_Unit::
382 * Attribute Stub_Type::
383 * Attribute System_Allocator_Alignment::
384 * Attribute Target_Name::
385 * Attribute Tick::
386 * Attribute To_Address::
387 * Attribute Type_Class::
388 * Attribute UET_Address::
389 * Attribute Unconstrained_Array::
390 * Attribute Universal_Literal_String::
391 * Attribute Unrestricted_Access::
392 * Attribute Update::
393 * Attribute Valid_Scalars::
394 * Attribute VADS_Size::
395 * Attribute Value_Size::
396 * Attribute Wchar_T_Size::
397 * Attribute Word_Size::
398
399 Standard and Implementation Defined Restrictions
400
401 * Partition-Wide Restrictions::
402 * Program Unit Level Restrictions::
403
404 Partition-Wide Restrictions
405
406 * Immediate_Reclamation::
407 * Max_Asynchronous_Select_Nesting::
408 * Max_Entry_Queue_Length::
409 * Max_Protected_Entries::
410 * Max_Select_Alternatives::
411 * Max_Storage_At_Blocking::
412 * Max_Task_Entries::
413 * Max_Tasks::
414 * No_Abort_Statements::
415 * No_Access_Parameter_Allocators::
416 * No_Access_Subprograms::
417 * No_Allocators::
418 * No_Anonymous_Allocators::
419 * No_Calendar::
420 * No_Coextensions::
421 * No_Default_Initialization::
422 * No_Delay::
423 * No_Dependence::
424 * No_Direct_Boolean_Operators::
425 * No_Dispatch::
426 * No_Dispatching_Calls::
427 * No_Dynamic_Attachment::
428 * No_Dynamic_Priorities::
429 * No_Entry_Calls_In_Elaboration_Code::
430 * No_Enumeration_Maps::
431 * No_Exception_Handlers::
432 * No_Exception_Propagation::
433 * No_Exception_Registration::
434 * No_Exceptions::
435 * No_Finalization::
436 * No_Fixed_Point::
437 * No_Floating_Point::
438 * No_Implicit_Conditionals::
439 * No_Implicit_Dynamic_Code::
440 * No_Implicit_Heap_Allocations::
441 * No_Implicit_Loops::
442 * No_Initialize_Scalars::
443 * No_IO::
444 * No_Local_Allocators::
445 * No_Local_Protected_Objects::
446 * No_Local_Timing_Events::
447 * No_Long_Long_Integers::
448 * No_Nested_Finalization::
449 * No_Protected_Type_Allocators::
450 * No_Protected_Types::
451 * No_Recursion::
452 * No_Reentrancy::
453 * No_Relative_Delay::
454 * No_Requeue_Statements::
455 * No_Secondary_Stack::
456 * No_Select_Statements::
457 * No_Specific_Termination_Handlers::
458 * No_Specification_of_Aspect::
459 * No_Standard_Allocators_After_Elaboration::
460 * No_Standard_Storage_Pools::
461 * No_Stream_Optimizations::
462 * No_Streams::
463 * No_Task_Allocators::
464 * No_Task_Attributes_Package::
465 * No_Task_Hierarchy::
466 * No_Task_Termination::
467 * No_Tasking::
468 * No_Terminate_Alternatives::
469 * No_Unchecked_Access::
470 * Simple_Barriers::
471 * Static_Priorities::
472 * Static_Storage_Size::
473
474 Program Unit Level Restrictions
475
476 * No_Elaboration_Code::
477 * No_Entry_Queue::
478 * No_Implementation_Aspect_Specifications::
479 * No_Implementation_Attributes::
480 * No_Implementation_Identifiers::
481 * No_Implementation_Pragmas::
482 * No_Implementation_Restrictions::
483 * No_Implementation_Units::
484 * No_Implicit_Aliasing::
485 * No_Obsolescent_Features::
486 * No_Wide_Characters::
487 * SPARK_05::
488
489 The Implementation of Standard I/O
490
491 * Standard I/O Packages::
492 * FORM Strings::
493 * Direct_IO::
494 * Sequential_IO::
495 * Text_IO::
496 * Wide_Text_IO::
497 * Wide_Wide_Text_IO::
498 * Stream_IO::
499 * Text Translation::
500 * Shared Files::
501 * Filenames encoding::
502 * Open Modes::
503 * Operations on C Streams::
504 * Interfacing to C Streams::
505
506 The GNAT Library
507
508 * Ada.Characters.Latin_9 (a-chlat9.ads)::
509 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
510 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
511 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
512 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
513 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
514 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
515 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
516 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
517 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
518 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
519 * Ada.Command_Line.Environment (a-colien.ads)::
520 * Ada.Command_Line.Remove (a-colire.ads)::
521 * Ada.Command_Line.Response_File (a-clrefi.ads)::
522 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
523 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
524 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
525 * Ada.Exceptions.Traceback (a-exctra.ads)::
526 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
527 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
528 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
529 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
530 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
531 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
532 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
533 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
534 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
535 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
536 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
537 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
538 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
539 * GNAT.Altivec (g-altive.ads)::
540 * GNAT.Altivec.Conversions (g-altcon.ads)::
541 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
542 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
543 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
544 * GNAT.Array_Split (g-arrspl.ads)::
545 * GNAT.AWK (g-awk.ads)::
546 * GNAT.Bounded_Buffers (g-boubuf.ads)::
547 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
548 * GNAT.Bubble_Sort (g-bubsor.ads)::
549 * GNAT.Bubble_Sort_A (g-busora.ads)::
550 * GNAT.Bubble_Sort_G (g-busorg.ads)::
551 * GNAT.Byte_Order_Mark (g-byorma.ads)::
552 * GNAT.Byte_Swapping (g-bytswa.ads)::
553 * GNAT.Calendar (g-calend.ads)::
554 * GNAT.Calendar.Time_IO (g-catiio.ads)::
555 * GNAT.Case_Util (g-casuti.ads)::
556 * GNAT.CGI (g-cgi.ads)::
557 * GNAT.CGI.Cookie (g-cgicoo.ads)::
558 * GNAT.CGI.Debug (g-cgideb.ads)::
559 * GNAT.Command_Line (g-comlin.ads)::
560 * GNAT.Compiler_Version (g-comver.ads)::
561 * GNAT.Ctrl_C (g-ctrl_c.ads)::
562 * GNAT.CRC32 (g-crc32.ads)::
563 * GNAT.Current_Exception (g-curexc.ads)::
564 * GNAT.Debug_Pools (g-debpoo.ads)::
565 * GNAT.Debug_Utilities (g-debuti.ads)::
566 * GNAT.Decode_String (g-decstr.ads)::
567 * GNAT.Decode_UTF8_String (g-deutst.ads)::
568 * GNAT.Directory_Operations (g-dirope.ads)::
569 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
570 * GNAT.Dynamic_HTables (g-dynhta.ads)::
571 * GNAT.Dynamic_Tables (g-dyntab.ads)::
572 * GNAT.Encode_String (g-encstr.ads)::
573 * GNAT.Encode_UTF8_String (g-enutst.ads)::
574 * GNAT.Exception_Actions (g-excact.ads)::
575 * GNAT.Exception_Traces (g-exctra.ads)::
576 * GNAT.Exceptions (g-except.ads)::
577 * GNAT.Expect (g-expect.ads)::
578 * GNAT.Expect.TTY (g-exptty.ads)::
579 * GNAT.Float_Control (g-flocon.ads)::
580 * GNAT.Heap_Sort (g-heasor.ads)::
581 * GNAT.Heap_Sort_A (g-hesora.ads)::
582 * GNAT.Heap_Sort_G (g-hesorg.ads)::
583 * GNAT.HTable (g-htable.ads)::
584 * GNAT.IO (g-io.ads)::
585 * GNAT.IO_Aux (g-io_aux.ads)::
586 * GNAT.Lock_Files (g-locfil.ads)::
587 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
588 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
589 * GNAT.MD5 (g-md5.ads)::
590 * GNAT.Memory_Dump (g-memdum.ads)::
591 * GNAT.Most_Recent_Exception (g-moreex.ads)::
592 * GNAT.OS_Lib (g-os_lib.ads)::
593 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
594 * GNAT.Random_Numbers (g-rannum.ads)::
595 * GNAT.Regexp (g-regexp.ads)::
596 * GNAT.Registry (g-regist.ads)::
597 * GNAT.Regpat (g-regpat.ads)::
598 * GNAT.Rewrite_Data (g-rewdat.ads)::
599 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
600 * GNAT.Semaphores (g-semaph.ads)::
601 * GNAT.Serial_Communications (g-sercom.ads)::
602 * GNAT.SHA1 (g-sha1.ads)::
603 * GNAT.SHA224 (g-sha224.ads)::
604 * GNAT.SHA256 (g-sha256.ads)::
605 * GNAT.SHA384 (g-sha384.ads)::
606 * GNAT.SHA512 (g-sha512.ads)::
607 * GNAT.Signals (g-signal.ads)::
608 * GNAT.Sockets (g-socket.ads)::
609 * GNAT.Source_Info (g-souinf.ads)::
610 * GNAT.Spelling_Checker (g-speche.ads)::
611 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
612 * GNAT.Spitbol.Patterns (g-spipat.ads)::
613 * GNAT.Spitbol (g-spitbo.ads)::
614 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
615 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
616 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
617 * GNAT.SSE (g-sse.ads)::
618 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
619 * GNAT.Strings (g-string.ads)::
620 * GNAT.String_Split (g-strspl.ads)::
621 * GNAT.Table (g-table.ads)::
622 * GNAT.Task_Lock (g-tasloc.ads)::
623 * GNAT.Threads (g-thread.ads)::
624 * GNAT.Time_Stamp (g-timsta.ads)::
625 * GNAT.Traceback (g-traceb.ads)::
626 * GNAT.Traceback.Symbolic (g-trasym.ads)::
627 * GNAT.UTF_32 (g-utf_32.ads)::
628 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
629 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
630 * GNAT.Wide_String_Split (g-wistsp.ads)::
631 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
632 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
633 * Interfaces.C.Extensions (i-cexten.ads)::
634 * Interfaces.C.Streams (i-cstrea.ads)::
635 * Interfaces.CPP (i-cpp.ads)::
636 * Interfaces.Packed_Decimal (i-pacdec.ads)::
637 * Interfaces.VxWorks (i-vxwork.ads)::
638 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
639 * System.Address_Image (s-addima.ads)::
640 * System.Assertions (s-assert.ads)::
641 * System.Memory (s-memory.ads)::
642 * System.Multiprocessors (s-multip.ads)::
643 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
644 * System.Partition_Interface (s-parint.ads)::
645 * System.Pool_Global (s-pooglo.ads)::
646 * System.Pool_Local (s-pooloc.ads)::
647 * System.Restrictions (s-restri.ads)::
648 * System.Rident (s-rident.ads)::
649 * System.Strings.Stream_Ops (s-ststop.ads)::
650 * System.Unsigned_Types (s-unstyp.ads)::
651 * System.Wch_Cnv (s-wchcnv.ads)::
652 * System.Wch_Con (s-wchcon.ads)::
653
654 Text_IO
655
656 * Text_IO Stream Pointer Positioning::
657 * Text_IO Reading and Writing Non-Regular Files::
658 * Get_Immediate::
659 * Treating Text_IO Files as Streams::
660 * Text_IO Extensions::
661 * Text_IO Facilities for Unbounded Strings::
662
663 Wide_Text_IO
664
665 * Wide_Text_IO Stream Pointer Positioning::
666 * Wide_Text_IO Reading and Writing Non-Regular Files::
667
668 Wide_Wide_Text_IO
669
670 * Wide_Wide_Text_IO Stream Pointer Positioning::
671 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
672
673 Interfacing to Other Languages
674
675 * Interfacing to C::
676 * Interfacing to C++::
677 * Interfacing to COBOL::
678 * Interfacing to Fortran::
679 * Interfacing to non-GNAT Ada code::
680
681 Specialized Needs Annexes
682
683 Implementation of Specific Ada Features
684 * Machine Code Insertions::
685 * GNAT Implementation of Tasking::
686 * GNAT Implementation of Shared Passive Packages::
687 * Code Generation for Array Aggregates::
688 * The Size of Discriminated Records with Default Discriminants::
689 * Strict Conformance to the Ada Reference Manual::
690
691 Implementation of Ada 2012 Features
692
693 Obsolescent Features
694
695 GNU Free Documentation License
696
697 Index
698 @end menu
699
700 @end ifnottex
701
702 @node About This Guide
703 @unnumbered About This Guide
704
705 @noindent
706 This manual contains useful information in writing programs using the
707 @value{EDITION} compiler. It includes information on implementation dependent
708 characteristics of @value{EDITION}, including all the information required by
709 Annex M of the Ada language standard.
710
711 @value{EDITION} implements Ada 95, Ada 2005 and Ada 2012, and it may also be
712 invoked in Ada 83 compatibility mode.
713 By default, @value{EDITION} assumes Ada 2012,
714 but you can override with a compiler switch
715 to explicitly specify the language version.
716 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
717 @value{EDITION} User's Guide}, for details on these switches.)
718 Throughout this manual, references to ``Ada'' without a year suffix
719 apply to all the Ada versions of the language.
720
721 Ada is designed to be highly portable.
722 In general, a program will have the same effect even when compiled by
723 different compilers on different platforms.
724 However, since Ada is designed to be used in a
725 wide variety of applications, it also contains a number of system
726 dependent features to be used in interfacing to the external world.
727 @cindex Implementation-dependent features
728 @cindex Portability
729
730 Note: Any program that makes use of implementation-dependent features
731 may be non-portable. You should follow good programming practice and
732 isolate and clearly document any sections of your program that make use
733 of these features in a non-portable manner.
734
735 @ifset PROEDITION
736 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
737 ``GNAT'' in the remainder of this document.
738 @end ifset
739
740 @menu
741 * What This Reference Manual Contains::
742 * Conventions::
743 * Related Information::
744 @end menu
745
746 @node What This Reference Manual Contains
747 @unnumberedsec What This Reference Manual Contains
748
749 @noindent
750 This reference manual contains the following chapters:
751
752 @itemize @bullet
753 @item
754 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
755 pragmas, which can be used to extend and enhance the functionality of the
756 compiler.
757
758 @item
759 @ref{Implementation Defined Attributes}, lists GNAT
760 implementation-dependent attributes, which can be used to extend and
761 enhance the functionality of the compiler.
762
763 @item
764 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
765 implementation-dependent restrictions, which can be used to extend and
766 enhance the functionality of the compiler.
767
768 @item
769 @ref{Implementation Advice}, provides information on generally
770 desirable behavior which are not requirements that all compilers must
771 follow since it cannot be provided on all systems, or which may be
772 undesirable on some systems.
773
774 @item
775 @ref{Implementation Defined Characteristics}, provides a guide to
776 minimizing implementation dependent features.
777
778 @item
779 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
780 implemented by GNAT, and how they can be imported into user
781 application programs.
782
783 @item
784 @ref{Representation Clauses and Pragmas}, describes in detail the
785 way that GNAT represents data, and in particular the exact set
786 of representation clauses and pragmas that is accepted.
787
788 @item
789 @ref{Standard Library Routines}, provides a listing of packages and a
790 brief description of the functionality that is provided by Ada's
791 extensive set of standard library routines as implemented by GNAT@.
792
793 @item
794 @ref{The Implementation of Standard I/O}, details how the GNAT
795 implementation of the input-output facilities.
796
797 @item
798 @ref{The GNAT Library}, is a catalog of packages that complement
799 the Ada predefined library.
800
801 @item
802 @ref{Interfacing to Other Languages}, describes how programs
803 written in Ada using GNAT can be interfaced to other programming
804 languages.
805
806 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
807 of the specialized needs annexes.
808
809 @item
810 @ref{Implementation of Specific Ada Features}, discusses issues related
811 to GNAT's implementation of machine code insertions, tasking, and several
812 other features.
813
814 @item
815 @ref{Implementation of Ada 2012 Features}, describes the status of the
816 GNAT implementation of the Ada 2012 language standard.
817
818 @item
819 @ref{Obsolescent Features} documents implementation dependent features,
820 including pragmas and attributes, which are considered obsolescent, since
821 there are other preferred ways of achieving the same results. These
822 obsolescent forms are retained for backwards compatibility.
823
824 @end itemize
825
826 @cindex Ada 95 Language Reference Manual
827 @cindex Ada 2005 Language Reference Manual
828 @noindent
829 This reference manual assumes a basic familiarity with the Ada 95 language, as
830 described in the International Standard ANSI/ISO/IEC-8652:1995,
831 January 1995.
832 It does not require knowledge of the new features introduced by Ada 2005,
833 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
834 and Amendment 1).
835 Both reference manuals are included in the GNAT documentation
836 package.
837
838 @node Conventions
839 @unnumberedsec Conventions
840 @cindex Conventions, typographical
841 @cindex Typographical conventions
842
843 @noindent
844 Following are examples of the typographical and graphic conventions used
845 in this guide:
846
847 @itemize @bullet
848 @item
849 @code{Functions}, @code{utility program names}, @code{standard names},
850 and @code{classes}.
851
852 @item
853 @code{Option flags}
854
855 @item
856 @file{File names}, @samp{button names}, and @samp{field names}.
857
858 @item
859 @code{Variables}, @env{environment variables}, and @var{metasyntactic
860 variables}.
861
862 @item
863 @emph{Emphasis}.
864
865 @item
866 [optional information or parameters]
867
868 @item
869 Examples are described by text
870 @smallexample
871 and then shown this way.
872 @end smallexample
873 @end itemize
874
875 @noindent
876 Commands that are entered by the user are preceded in this manual by the
877 characters @samp{$ } (dollar sign followed by space). If your system uses this
878 sequence as a prompt, then the commands will appear exactly as you see them
879 in the manual. If your system uses some other prompt, then the command will
880 appear with the @samp{$} replaced by whatever prompt character you are using.
881
882 @node Related Information
883 @unnumberedsec Related Information
884 @noindent
885 See the following documents for further information on GNAT:
886
887 @itemize @bullet
888 @item
889 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
890 @value{EDITION} User's Guide}, which provides information on how to use the
891 GNAT compiler system.
892
893 @item
894 @cite{Ada 95 Reference Manual}, which contains all reference
895 material for the Ada 95 programming language.
896
897 @item
898 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
899 of the Ada 95 standard. The annotations describe
900 detailed aspects of the design decision, and in particular contain useful
901 sections on Ada 83 compatibility.
902
903 @item
904 @cite{Ada 2005 Reference Manual}, which contains all reference
905 material for the Ada 2005 programming language.
906
907 @item
908 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
909 of the Ada 2005 standard. The annotations describe
910 detailed aspects of the design decision, and in particular contain useful
911 sections on Ada 83 and Ada 95 compatibility.
912
913 @item
914 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
915 which contains specific information on compatibility between GNAT and
916 DEC Ada 83 systems.
917
918 @item
919 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
920 describes in detail the pragmas and attributes provided by the DEC Ada 83
921 compiler system.
922
923 @end itemize
924
925 @node Implementation Defined Pragmas
926 @chapter Implementation Defined Pragmas
927
928 @noindent
929 Ada defines a set of pragmas that can be used to supply additional
930 information to the compiler. These language defined pragmas are
931 implemented in GNAT and work as described in the Ada Reference Manual.
932
933 In addition, Ada allows implementations to define additional pragmas
934 whose meaning is defined by the implementation. GNAT provides a number
935 of these implementation-defined pragmas, which can be used to extend
936 and enhance the functionality of the compiler. This section of the GNAT
937 Reference Manual describes these additional pragmas.
938
939 Note that any program using these pragmas might not be portable to other
940 compilers (although GNAT implements this set of pragmas on all
941 platforms). Therefore if portability to other compilers is an important
942 consideration, the use of these pragmas should be minimized.
943
944 @menu
945 * Pragma Abort_Defer::
946 * Pragma Abstract_State::
947 * Pragma Ada_83::
948 * Pragma Ada_95::
949 * Pragma Ada_05::
950 * Pragma Ada_2005::
951 * Pragma Ada_12::
952 * Pragma Ada_2012::
953 * Pragma Allow_Integer_Address::
954 * Pragma Annotate::
955 * Pragma Assert::
956 * Pragma Assert_And_Cut::
957 * Pragma Assertion_Policy::
958 * Pragma Assume::
959 * Pragma Assume_No_Invalid_Values::
960 * Pragma Async_Readers::
961 * Pragma Async_Writers::
962 * Pragma Attribute_Definition::
963 * Pragma Ast_Entry::
964 * Pragma C_Pass_By_Copy::
965 * Pragma Check::
966 * Pragma Check_Float_Overflow::
967 * Pragma Check_Name::
968 * Pragma Check_Policy::
969 * Pragma CIL_Constructor::
970 * Pragma Comment::
971 * Pragma Common_Object::
972 * Pragma Compile_Time_Error::
973 * Pragma Compile_Time_Warning::
974 * Pragma Compiler_Unit::
975 * Pragma Compiler_Unit_Warning::
976 * Pragma Complete_Representation::
977 * Pragma Complex_Representation::
978 * Pragma Component_Alignment::
979 * Pragma Contract_Cases::
980 * Pragma Convention_Identifier::
981 * Pragma CPP_Class::
982 * Pragma CPP_Constructor::
983 * Pragma CPP_Virtual::
984 * Pragma CPP_Vtable::
985 * Pragma CPU::
986 * Pragma Debug::
987 * Pragma Debug_Policy::
988 * Pragma Default_Storage_Pool::
989 * Pragma Depends::
990 * Pragma Detect_Blocking::
991 * Pragma Disable_Atomic_Synchronization::
992 * Pragma Dispatching_Domain::
993 * Pragma Effective_Reads::
994 * Pragma Effective_Writes::
995 * Pragma Elaboration_Checks::
996 * Pragma Eliminate::
997 * Pragma Enable_Atomic_Synchronization::
998 * Pragma Export_Exception::
999 * Pragma Export_Function::
1000 * Pragma Export_Object::
1001 * Pragma Export_Procedure::
1002 * Pragma Export_Value::
1003 * Pragma Export_Valued_Procedure::
1004 * Pragma Extend_System::
1005 * Pragma Extensions_Allowed::
1006 * Pragma External::
1007 * Pragma External_Name_Casing::
1008 * Pragma Fast_Math::
1009 * Pragma Favor_Top_Level::
1010 * Pragma Finalize_Storage_Only::
1011 * Pragma Float_Representation::
1012 * Pragma Global::
1013 * Pragma Ident::
1014 * Pragma Implementation_Defined::
1015 * Pragma Implemented::
1016 * Pragma Implicit_Packing::
1017 * Pragma Import_Exception::
1018 * Pragma Import_Function::
1019 * Pragma Import_Object::
1020 * Pragma Import_Procedure::
1021 * Pragma Import_Valued_Procedure::
1022 * Pragma Independent::
1023 * Pragma Independent_Components::
1024 * Pragma Initial_Condition::
1025 * Pragma Initialize_Scalars::
1026 * Pragma Initializes::
1027 * Pragma Inline_Always::
1028 * Pragma Inline_Generic::
1029 * Pragma Interface::
1030 * Pragma Interface_Name::
1031 * Pragma Interrupt_Handler::
1032 * Pragma Interrupt_State::
1033 * Pragma Invariant::
1034 * Pragma Java_Constructor::
1035 * Pragma Java_Interface::
1036 * Pragma Keep_Names::
1037 * Pragma License::
1038 * Pragma Link_With::
1039 * Pragma Linker_Alias::
1040 * Pragma Linker_Constructor::
1041 * Pragma Linker_Destructor::
1042 * Pragma Linker_Section::
1043 * Pragma Long_Float::
1044 * Pragma Loop_Invariant::
1045 * Pragma Loop_Optimize::
1046 * Pragma Loop_Variant::
1047 * Pragma Machine_Attribute::
1048 * Pragma Main::
1049 * Pragma Main_Storage::
1050 * Pragma No_Body::
1051 * Pragma No_Inline::
1052 * Pragma No_Return::
1053 * Pragma No_Run_Time::
1054 * Pragma No_Strict_Aliasing::
1055 * Pragma Normalize_Scalars::
1056 * Pragma Obsolescent::
1057 * Pragma Optimize_Alignment::
1058 * Pragma Ordered::
1059 * Pragma Overflow_Mode::
1060 * Pragma Overriding_Renamings::
1061 * Pragma Partition_Elaboration_Policy::
1062 * Pragma Part_Of::
1063 * Pragma Passive::
1064 * Pragma Persistent_BSS::
1065 * Pragma Polling::
1066 * Pragma Post::
1067 * Pragma Postcondition::
1068 * Pragma Post_Class::
1069 * Pragma Pre::
1070 * Pragma Precondition::
1071 * Pragma Predicate::
1072 * Pragma Preelaborable_Initialization::
1073 * Pragma Pre_Class::
1074 * Pragma Priority_Specific_Dispatching::
1075 * Pragma Profile::
1076 * Pragma Profile_Warnings::
1077 * Pragma Propagate_Exceptions::
1078 * Pragma Provide_Shift_Operators::
1079 * Pragma Psect_Object::
1080 * Pragma Pure_Function::
1081 * Pragma Ravenscar::
1082 * Pragma Refined_Depends::
1083 * Pragma Refined_Global::
1084 * Pragma Refined_Post::
1085 * Pragma Refined_State::
1086 * Pragma Relative_Deadline::
1087 * Pragma Remote_Access_Type::
1088 * Pragma Restricted_Run_Time::
1089 * Pragma Restriction_Warnings::
1090 * Pragma Reviewable::
1091 * Pragma Share_Generic::
1092 * Pragma Shared::
1093 * Pragma Short_Circuit_And_Or::
1094 * Pragma Short_Descriptors::
1095 * Pragma Simple_Storage_Pool_Type::
1096 * Pragma Source_File_Name::
1097 * Pragma Source_File_Name_Project::
1098 * Pragma Source_Reference::
1099 * Pragma SPARK_Mode::
1100 * Pragma Static_Elaboration_Desired::
1101 * Pragma Stream_Convert::
1102 * Pragma Style_Checks::
1103 * Pragma Subtitle::
1104 * Pragma Suppress::
1105 * Pragma Suppress_All::
1106 * Pragma Suppress_Debug_Info::
1107 * Pragma Suppress_Exception_Locations::
1108 * Pragma Suppress_Initialization::
1109 * Pragma Task_Name::
1110 * Pragma Task_Storage::
1111 * Pragma Test_Case::
1112 * Pragma Thread_Local_Storage::
1113 * Pragma Time_Slice::
1114 * Pragma Title::
1115 * Pragma Type_Invariant::
1116 * Pragma Type_Invariant_Class::
1117 * Pragma Unchecked_Union::
1118 * Pragma Unimplemented_Unit::
1119 * Pragma Universal_Aliasing ::
1120 * Pragma Universal_Data::
1121 * Pragma Unmodified::
1122 * Pragma Unreferenced::
1123 * Pragma Unreferenced_Objects::
1124 * Pragma Unreserve_All_Interrupts::
1125 * Pragma Unsuppress::
1126 * Pragma Use_VADS_Size::
1127 * Pragma Validity_Checks::
1128 * Pragma Volatile::
1129 * Pragma Warning_As_Error::
1130 * Pragma Warnings::
1131 * Pragma Weak_External::
1132 * Pragma Wide_Character_Encoding::
1133 @end menu
1134
1135 @node Pragma Abort_Defer
1136 @unnumberedsec Pragma Abort_Defer
1137 @findex Abort_Defer
1138 @cindex Deferring aborts
1139 @noindent
1140 Syntax:
1141 @smallexample
1142 pragma Abort_Defer;
1143 @end smallexample
1144
1145 @noindent
1146 This pragma must appear at the start of the statement sequence of a
1147 handled sequence of statements (right after the @code{begin}). It has
1148 the effect of deferring aborts for the sequence of statements (but not
1149 for the declarations or handlers, if any, associated with this statement
1150 sequence).
1151
1152 @node Pragma Abstract_State
1153 @unnumberedsec Pragma Abstract_State
1154 @findex Abstract_State
1155 @noindent
1156 For the description of this pragma, see SPARK 2014 Reference Manual,
1157 section 7.1.4.
1158
1159 @node Pragma Ada_83
1160 @unnumberedsec Pragma Ada_83
1161 @findex Ada_83
1162 @noindent
1163 Syntax:
1164 @smallexample @c ada
1165 pragma Ada_83;
1166 @end smallexample
1167
1168 @noindent
1169 A configuration pragma that establishes Ada 83 mode for the unit to
1170 which it applies, regardless of the mode set by the command line
1171 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1172 the syntax and semantics of Ada 83, as defined in the original Ada
1173 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1174 and Ada 2005 are not recognized, optional package bodies are allowed,
1175 and generics may name types with unknown discriminants without using
1176 the @code{(<>)} notation. In addition, some but not all of the additional
1177 restrictions of Ada 83 are enforced.
1178
1179 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1180 Ada 83 code to be compiled and adapted to GNAT with less effort.
1181 Secondly, it aids in keeping code backwards compatible with Ada 83.
1182 However, there is no guarantee that code that is processed correctly
1183 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1184 83 compiler, since GNAT does not enforce all the additional checks
1185 required by Ada 83.
1186
1187 @node Pragma Ada_95
1188 @unnumberedsec Pragma Ada_95
1189 @findex Ada_95
1190 @noindent
1191 Syntax:
1192 @smallexample @c ada
1193 pragma Ada_95;
1194 @end smallexample
1195
1196 @noindent
1197 A configuration pragma that establishes Ada 95 mode for the unit to which
1198 it applies, regardless of the mode set by the command line switches.
1199 This mode is set automatically for the @code{Ada} and @code{System}
1200 packages and their children, so you need not specify it in these
1201 contexts. This pragma is useful when writing a reusable component that
1202 itself uses Ada 95 features, but which is intended to be usable from
1203 either Ada 83 or Ada 95 programs.
1204
1205 @node Pragma Ada_05
1206 @unnumberedsec Pragma Ada_05
1207 @findex Ada_05
1208 @noindent
1209 Syntax:
1210 @smallexample @c ada
1211 pragma Ada_05;
1212 pragma Ada_05 (local_NAME);
1213 @end smallexample
1214
1215 @noindent
1216 A configuration pragma that establishes Ada 2005 mode for the unit to which
1217 it applies, regardless of the mode set by the command line switches.
1218 This pragma is useful when writing a reusable component that
1219 itself uses Ada 2005 features, but which is intended to be usable from
1220 either Ada 83 or Ada 95 programs.
1221
1222 The one argument form (which is not a configuration pragma)
1223 is used for managing the transition from
1224 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
1225 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
1226 mode will generate a warning. In addition, in Ada_83 or Ada_95
1227 mode, a preference rule is established which does not choose
1228 such an entity unless it is unambiguously specified. This avoids
1229 extra subprograms marked this way from generating ambiguities in
1230 otherwise legal pre-Ada_2005 programs. The one argument form is
1231 intended for exclusive use in the GNAT run-time library.
1232
1233 @node Pragma Ada_2005
1234 @unnumberedsec Pragma Ada_2005
1235 @findex Ada_2005
1236 @noindent
1237 Syntax:
1238 @smallexample @c ada
1239 pragma Ada_2005;
1240 @end smallexample
1241
1242 @noindent
1243 This configuration pragma is a synonym for pragma Ada_05 and has the
1244 same syntax and effect.
1245
1246 @node Pragma Ada_12
1247 @unnumberedsec Pragma Ada_12
1248 @findex Ada_12
1249 @noindent
1250 Syntax:
1251 @smallexample @c ada
1252 pragma Ada_12;
1253 pragma Ada_12 (local_NAME);
1254 @end smallexample
1255
1256 @noindent
1257 A configuration pragma that establishes Ada 2012 mode for the unit to which
1258 it applies, regardless of the mode set by the command line switches.
1259 This mode is set automatically for the @code{Ada} and @code{System}
1260 packages and their children, so you need not specify it in these
1261 contexts. This pragma is useful when writing a reusable component that
1262 itself uses Ada 2012 features, but which is intended to be usable from
1263 Ada 83, Ada 95, or Ada 2005 programs.
1264
1265 The one argument form, which is not a configuration pragma,
1266 is used for managing the transition from Ada
1267 2005 to Ada 2012 in the run-time library. If an entity is marked
1268 as Ada_201 only, then referencing the entity in any pre-Ada_2012
1269 mode will generate a warning. In addition, in any pre-Ada_2012
1270 mode, a preference rule is established which does not choose
1271 such an entity unless it is unambiguously specified. This avoids
1272 extra subprograms marked this way from generating ambiguities in
1273 otherwise legal pre-Ada_2012 programs. The one argument form is
1274 intended for exclusive use in the GNAT run-time library.
1275
1276 @node Pragma Ada_2012
1277 @unnumberedsec Pragma Ada_2012
1278 @findex Ada_2005
1279 @noindent
1280 Syntax:
1281 @smallexample @c ada
1282 pragma Ada_2012;
1283 @end smallexample
1284
1285 @noindent
1286 This configuration pragma is a synonym for pragma Ada_12 and has the
1287 same syntax and effect.
1288
1289 @node Pragma Allow_Integer_Address
1290 @unnumberedsec Pragma Allow_Integer_Address
1291 @findex Allow_Integer_Address
1292 @noindent
1293 Syntax:
1294 @smallexample @c ada
1295 pragma Allow_Integer_Address;
1296 @end smallexample
1297
1298 @noindent
1299 In almost all versions of GNAT, @code{System.Address} is a private
1300 type in accordance with the implementation advice in the RM. This
1301 means that integer values,
1302 in particular integer literals, are not allowed as address values.
1303 If the configuration pragma
1304 @code{Allow_Integer_Address} is given, then integer expressions may
1305 be used anywhere a value of type @code{System.Address} is required.
1306 The effect is to introduce an implicit unchecked conversion from the
1307 integer value to type @code{System.Address}. The reverse case of using
1308 an address where an integer type is required is handled analogously.
1309 The following example compiles without errors:
1310
1311 @smallexample @c ada
1312 pragma Allow_Integer_Address;
1313 with System; use System;
1314 package AddrAsInt is
1315 X : Integer;
1316 Y : Integer;
1317 for X'Address use 16#1240#;
1318 for Y use at 16#3230#;
1319 m : Address := 16#4000#;
1320 n : constant Address := 4000;
1321 p : constant Address := Address (X + Y);
1322 v : Integer := y'Address;
1323 w : constant Integer := Integer (Y'Address);
1324 type R is new integer;
1325 RR : R := 1000;
1326 Z : Integer;
1327 for Z'Address use RR;
1328 end AddrAsInt;
1329 @end smallexample
1330
1331 @noindent
1332 Note that pragma @code{Allow_Integer_Address} is ignored if
1333 @code{System.Address}
1334 is not a private type. In implementations of @code{GNAT} where
1335 System.Address is a visible integer type (notably the implementations
1336 for @code{OpenVMS}), this pragma serves no purpose but is ignored
1337 rather than rejected to allow common sets of sources to be used
1338 in the two situations.
1339
1340 @node Pragma Annotate
1341 @unnumberedsec Pragma Annotate
1342 @findex Annotate
1343 @noindent
1344 Syntax:
1345 @smallexample @c ada
1346 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1347
1348 ARG ::= NAME | EXPRESSION
1349 @end smallexample
1350
1351 @noindent
1352 This pragma is used to annotate programs. @var{identifier} identifies
1353 the type of annotation. GNAT verifies that it is an identifier, but does
1354 not otherwise analyze it. The second optional identifier is also left
1355 unanalyzed, and by convention is used to control the action of the tool to
1356 which the annotation is addressed. The remaining @var{arg} arguments
1357 can be either string literals or more generally expressions.
1358 String literals are assumed to be either of type
1359 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1360 depending on the character literals they contain.
1361 All other kinds of arguments are analyzed as expressions, and must be
1362 unambiguous.
1363
1364 The analyzed pragma is retained in the tree, but not otherwise processed
1365 by any part of the GNAT compiler, except to generate corresponding note
1366 lines in the generated ALI file. For the format of these note lines, see
1367 the compiler source file lib-writ.ads. This pragma is intended for use by
1368 external tools, including ASIS@. The use of pragma Annotate does not
1369 affect the compilation process in any way. This pragma may be used as
1370 a configuration pragma.
1371
1372 @node Pragma Assert
1373 @unnumberedsec Pragma Assert
1374 @findex Assert
1375 @noindent
1376 Syntax:
1377 @smallexample @c ada
1378 pragma Assert (
1379 boolean_EXPRESSION
1380 [, string_EXPRESSION]);
1381 @end smallexample
1382
1383 @noindent
1384 The effect of this pragma depends on whether the corresponding command
1385 line switch is set to activate assertions. The pragma expands into code
1386 equivalent to the following:
1387
1388 @smallexample @c ada
1389 if assertions-enabled then
1390 if not boolean_EXPRESSION then
1391 System.Assertions.Raise_Assert_Failure
1392 (string_EXPRESSION);
1393 end if;
1394 end if;
1395 @end smallexample
1396
1397 @noindent
1398 The string argument, if given, is the message that will be associated
1399 with the exception occurrence if the exception is raised. If no second
1400 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1401 where @var{file} is the name of the source file containing the assert,
1402 and @var{nnn} is the line number of the assert. A pragma is not a
1403 statement, so if a statement sequence contains nothing but a pragma
1404 assert, then a null statement is required in addition, as in:
1405
1406 @smallexample @c ada
1407 @dots{}
1408 if J > 3 then
1409 pragma Assert (K > 3, "Bad value for K");
1410 null;
1411 end if;
1412 @end smallexample
1413
1414 @noindent
1415 Note that, as with the @code{if} statement to which it is equivalent, the
1416 type of the expression is either @code{Standard.Boolean}, or any type derived
1417 from this standard type.
1418
1419 Assert checks can be either checked or ignored. By default they are ignored.
1420 They will be checked if either the command line switch @option{-gnata} is
1421 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1422 to enable @code{Assert_Checks}.
1423
1424 If assertions are ignored, then there
1425 is no run-time effect (and in particular, any side effects from the
1426 expression will not occur at run time). (The expression is still
1427 analyzed at compile time, and may cause types to be frozen if they are
1428 mentioned here for the first time).
1429
1430 If assertions are checked, then the given expression is tested, and if
1431 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1432 which results in the raising of @code{Assert_Failure} with the given message.
1433
1434 You should generally avoid side effects in the expression arguments of
1435 this pragma, because these side effects will turn on and off with the
1436 setting of the assertions mode, resulting in assertions that have an
1437 effect on the program. However, the expressions are analyzed for
1438 semantic correctness whether or not assertions are enabled, so turning
1439 assertions on and off cannot affect the legality of a program.
1440
1441 Note that the implementation defined policy @code{DISABLE}, given in a
1442 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1443
1444 Note: this is a standard language-defined pragma in versions
1445 of Ada from 2005 on. In GNAT, it is implemented in all versions
1446 of Ada, and the DISABLE policy is an implementation-defined
1447 addition.
1448
1449 @node Pragma Assert_And_Cut
1450 @unnumberedsec Pragma Assert_And_Cut
1451 @findex Assert_And_Cut
1452 @noindent
1453 Syntax:
1454 @smallexample @c ada
1455 pragma Assert_And_Cut (
1456 boolean_EXPRESSION
1457 [, string_EXPRESSION]);
1458 @end smallexample
1459
1460 @noindent
1461 The effect of this pragma is identical to that of pragma @code{Assert},
1462 except that in an @code{Assertion_Policy} pragma, the identifier
1463 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1464 (or disabled).
1465
1466 The intention is that this be used within a subprogram when the
1467 given test expresion sums up all the work done so far in the
1468 subprogram, so that the rest of the subprogram can be verified
1469 (informally or formally) using only the entry preconditions,
1470 and the expression in this pragma. This allows dividing up
1471 a subprogram into sections for the purposes of testing or
1472 formal verification. The pragma also serves as useful
1473 documentation.
1474
1475 @node Pragma Assertion_Policy
1476 @unnumberedsec Pragma Assertion_Policy
1477 @findex Assertion_Policy
1478 @noindent
1479 Syntax:
1480 @smallexample @c ada
1481 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1482
1483 pragma Assertion_Policy (
1484 ASSERTION_KIND => POLICY_IDENTIFIER
1485 @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1486
1487 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1488
1489 RM_ASSERTION_KIND ::= Assert |
1490 Static_Predicate |
1491 Dynamic_Predicate |
1492 Pre |
1493 Pre'Class |
1494 Post |
1495 Post'Class |
1496 Type_Invariant |
1497 Type_Invariant'Class
1498
1499 ID_ASSERTION_KIND ::= Assertions |
1500 Assert_And_Cut |
1501 Assume |
1502 Contract_Cases |
1503 Debug |
1504 Invariant |
1505 Invariant'Class |
1506 Loop_Invariant |
1507 Loop_Variant |
1508 Postcondition |
1509 Precondition |
1510 Predicate |
1511 Refined_Post |
1512 Statement_Assertions
1513
1514 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1515 @end smallexample
1516
1517 @noindent
1518 This is a standard Ada 2012 pragma that is available as an
1519 implementation-defined pragma in earlier versions of Ada.
1520 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1521 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1522 are implementation defined additions recognized by the GNAT compiler.
1523
1524 The pragma applies in both cases to pragmas and aspects with matching
1525 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1526 applies to both the @code{Precondition} pragma
1527 and the aspect @code{Precondition}. Note that the identifiers for
1528 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
1529 Pre_Class and Post_Class), since these pragmas are intended to be
1530 identical to the corresponding aspects).
1531
1532 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1533 the corresponding pragma or aspect is activated.
1534 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1535 the corresponding pragma or aspect is deactivated.
1536 This pragma overrides the effect of the @option{-gnata} switch on the
1537 command line.
1538
1539 The implementation defined policy @code{DISABLE} is like
1540 @code{IGNORE} except that it completely disables semantic
1541 checking of the corresponding pragma or aspect. This is
1542 useful when the pragma or aspect argument references subprograms
1543 in a with'ed package which is replaced by a dummy package
1544 for the final build.
1545
1546 The implementation defined policy @code{Assertions} applies to all
1547 assertion kinds. The form with no assertion kind given implies this
1548 choice, so it applies to all assertion kinds (RM defined, and
1549 implementation defined).
1550
1551 The implementation defined policy @code{Statement_Assertions}
1552 applies to @code{Assert}, @code{Assert_And_Cut},
1553 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1554
1555 @node Pragma Assume
1556 @unnumberedsec Pragma Assume
1557 @findex Assume
1558 @noindent
1559 Syntax:
1560 @smallexample @c ada
1561 pragma Assume (
1562 boolean_EXPRESSION
1563 [, string_EXPRESSION]);
1564 @end smallexample
1565
1566 @noindent
1567 The effect of this pragma is identical to that of pragma @code{Assert},
1568 except that in an @code{Assertion_Policy} pragma, the identifier
1569 @code{Assume} is used to control whether it is ignored or checked
1570 (or disabled).
1571
1572 The intention is that this be used for assumptions about the
1573 external environment. So you cannot expect to verify formally
1574 or informally that the condition is met, this must be
1575 established by examining things outside the program itself.
1576 For example, we may have code that depends on the size of
1577 @code{Long_Long_Integer} being at least 64. So we could write:
1578
1579 @smallexample @c ada
1580 pragma Assume (Long_Long_Integer'Size >= 64);
1581 @end smallexample
1582
1583 @noindent
1584 This assumption cannot be proved from the program itself,
1585 but it acts as a useful run-time check that the assumption
1586 is met, and documents the need to ensure that it is met by
1587 reference to information outside the program.
1588
1589 @node Pragma Assume_No_Invalid_Values
1590 @unnumberedsec Pragma Assume_No_Invalid_Values
1591 @findex Assume_No_Invalid_Values
1592 @cindex Invalid representations
1593 @cindex Invalid values
1594 @noindent
1595 Syntax:
1596 @smallexample @c ada
1597 pragma Assume_No_Invalid_Values (On | Off);
1598 @end smallexample
1599
1600 @noindent
1601 This is a configuration pragma that controls the assumptions made by the
1602 compiler about the occurrence of invalid representations (invalid values)
1603 in the code.
1604
1605 The default behavior (corresponding to an Off argument for this pragma), is
1606 to assume that values may in general be invalid unless the compiler can
1607 prove they are valid. Consider the following example:
1608
1609 @smallexample @c ada
1610 V1 : Integer range 1 .. 10;
1611 V2 : Integer range 11 .. 20;
1612 ...
1613 for J in V2 .. V1 loop
1614 ...
1615 end loop;
1616 @end smallexample
1617
1618 @noindent
1619 if V1 and V2 have valid values, then the loop is known at compile
1620 time not to execute since the lower bound must be greater than the
1621 upper bound. However in default mode, no such assumption is made,
1622 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1623 is given, the compiler will assume that any occurrence of a variable
1624 other than in an explicit @code{'Valid} test always has a valid
1625 value, and the loop above will be optimized away.
1626
1627 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1628 you know your code is free of uninitialized variables and other
1629 possible sources of invalid representations, and may result in
1630 more efficient code. A program that accesses an invalid representation
1631 with this pragma in effect is erroneous, so no guarantees can be made
1632 about its behavior.
1633
1634 It is peculiar though permissible to use this pragma in conjunction
1635 with validity checking (-gnatVa). In such cases, accessing invalid
1636 values will generally give an exception, though formally the program
1637 is erroneous so there are no guarantees that this will always be the
1638 case, and it is recommended that these two options not be used together.
1639
1640 @node Pragma Async_Readers
1641 @unnumberedsec Pragma Async_Readers
1642 @findex Async_Readers
1643 @noindent
1644 For the description of this pragma, see SPARK 2014 Reference Manual,
1645 section 7.1.2.
1646
1647 @node Pragma Async_Writers
1648 @unnumberedsec Pragma Async_Writers
1649 @findex Async_Writers
1650 @noindent
1651 For the description of this pragma, see SPARK 2014 Reference Manual,
1652 section 7.1.2.
1653
1654 @node Pragma Ast_Entry
1655 @unnumberedsec Pragma Ast_Entry
1656 @cindex OpenVMS
1657 @findex Ast_Entry
1658 @noindent
1659 Syntax:
1660 @smallexample @c ada
1661 pragma AST_Entry (entry_IDENTIFIER);
1662 @end smallexample
1663
1664 @noindent
1665 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1666 argument is the simple name of a single entry; at most one @code{AST_Entry}
1667 pragma is allowed for any given entry. This pragma must be used in
1668 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1669 the entry declaration and in the same task type specification or single task
1670 as the entry to which it applies. This pragma specifies that the given entry
1671 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1672 resulting from an OpenVMS system service call. The pragma does not affect
1673 normal use of the entry. For further details on this pragma, see the
1674 DEC Ada Language Reference Manual, section 9.12a.
1675
1676 @node Pragma Attribute_Definition
1677 @unnumberedsec Pragma Attribute_Definition
1678 @findex Attribute_Definition
1679 @noindent
1680 Syntax:
1681 @smallexample @c ada
1682 pragma Attribute_Definition
1683 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1684 [Entity =>] LOCAL_NAME,
1685 [Expression =>] EXPRESSION | NAME);
1686 @end smallexample
1687
1688 @noindent
1689 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1690 the attribute definition clause:
1691
1692 @smallexample @c ada
1693 for Entity'Attribute use Expression;
1694 @end smallexample
1695
1696 If @code{Attribute} is not a recognized attribute name, the pragma is
1697 ignored, and a warning is emitted. This allows source
1698 code to be written that takes advantage of some new attribute, while remaining
1699 compilable with earlier compilers.
1700
1701 @node Pragma C_Pass_By_Copy
1702 @unnumberedsec Pragma C_Pass_By_Copy
1703 @cindex Passing by copy
1704 @findex C_Pass_By_Copy
1705 @noindent
1706 Syntax:
1707 @smallexample @c ada
1708 pragma C_Pass_By_Copy
1709 ([Max_Size =>] static_integer_EXPRESSION);
1710 @end smallexample
1711
1712 @noindent
1713 Normally the default mechanism for passing C convention records to C
1714 convention subprograms is to pass them by reference, as suggested by RM
1715 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1716 this default, by requiring that record formal parameters be passed by
1717 copy if all of the following conditions are met:
1718
1719 @itemize @bullet
1720 @item
1721 The size of the record type does not exceed the value specified for
1722 @code{Max_Size}.
1723 @item
1724 The record type has @code{Convention C}.
1725 @item
1726 The formal parameter has this record type, and the subprogram has a
1727 foreign (non-Ada) convention.
1728 @end itemize
1729
1730 @noindent
1731 If these conditions are met the argument is passed by copy, i.e.@: in a
1732 manner consistent with what C expects if the corresponding formal in the
1733 C prototype is a struct (rather than a pointer to a struct).
1734
1735 You can also pass records by copy by specifying the convention
1736 @code{C_Pass_By_Copy} for the record type, or by using the extended
1737 @code{Import} and @code{Export} pragmas, which allow specification of
1738 passing mechanisms on a parameter by parameter basis.
1739
1740 @node Pragma Check
1741 @unnumberedsec Pragma Check
1742 @cindex Assertions
1743 @cindex Named assertions
1744 @findex Check
1745 @noindent
1746 Syntax:
1747 @smallexample @c ada
1748 pragma Check (
1749 [Name =>] CHECK_KIND,
1750 [Check =>] Boolean_EXPRESSION
1751 [, [Message =>] string_EXPRESSION] );
1752
1753 CHECK_KIND ::= IDENTIFIER |
1754 Pre'Class |
1755 Post'Class |
1756 Type_Invariant'Class |
1757 Invariant'Class
1758 @end smallexample
1759
1760 @noindent
1761 This pragma is similar to the predefined pragma @code{Assert} except that an
1762 extra identifier argument is present. In conjunction with pragma
1763 @code{Check_Policy}, this can be used to define groups of assertions that can
1764 be independently controlled. The identifier @code{Assertion} is special, it
1765 refers to the normal set of pragma @code{Assert} statements.
1766
1767 Checks introduced by this pragma are normally deactivated by default. They can
1768 be activated either by the command line option @option{-gnata}, which turns on
1769 all checks, or individually controlled using pragma @code{Check_Policy}.
1770
1771 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1772 permitted as check kinds, since this would cause confusion with the use
1773 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1774 pragmas, where they are used to refer to sets of assertions.
1775
1776 @node Pragma Check_Float_Overflow
1777 @unnumberedsec Pragma Check_Float_Overflow
1778 @cindex Floating-point overflow
1779 @findex Check_Float_Overflow
1780 @noindent
1781 Syntax:
1782 @smallexample @c ada
1783 pragma Check_Float_Overflow;
1784 @end smallexample
1785
1786 @noindent
1787 In Ada, the predefined floating-point types (@code{Short_Float},
1788 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1789 defined to be @emph{unconstrained}. This means that even though each
1790 has a well-defined base range, an operation that delivers a result
1791 outside this base range is not required to raise an exception.
1792 This implementation permission accommodates the notion
1793 of infinities in IEEE floating-point, and corresponds to the
1794 efficient execution mode on most machines. GNAT will not raise
1795 overflow exceptions on these machines; instead it will generate
1796 infinities and NaN's as defined in the IEEE standard.
1797
1798 Generating infinities, although efficient, is not always desirable.
1799 Often the preferable approach is to check for overflow, even at the
1800 (perhaps considerable) expense of run-time performance.
1801 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1802 range constraints -- and indeed such a subtype
1803 can have the same base range as its base type. For example:
1804
1805 @smallexample @c ada
1806 subtype My_Float is Float range Float'Range;
1807 @end smallexample
1808
1809 @noindent
1810 Here @code{My_Float} has the same range as
1811 @code{Float} but is constrained, so operations on
1812 @code{My_Float} values will be checked for overflow
1813 against this range.
1814
1815 This style will achieve the desired goal, but
1816 it is often more convenient to be able to simply use
1817 the standard predefined floating-point types as long
1818 as overflow checking could be guaranteed.
1819 The @code{Check_Float_Overflow}
1820 configuration pragma achieves this effect. If a unit is compiled
1821 subject to this configuration pragma, then all operations
1822 on predefined floating-point types including operations on
1823 base types of these floating-point types will be treated as
1824 though those types were constrained, and overflow checks
1825 will be generated. The @code{Constraint_Error}
1826 exception is raised if the result is out of range.
1827
1828 This mode can also be set by use of the compiler
1829 switch @option{-gnateF}.
1830
1831 @node Pragma Check_Name
1832 @unnumberedsec Pragma Check_Name
1833 @cindex Defining check names
1834 @cindex Check names, defining
1835 @findex Check_Name
1836 @noindent
1837 Syntax:
1838 @smallexample @c ada
1839 pragma Check_Name (check_name_IDENTIFIER);
1840 @end smallexample
1841
1842 @noindent
1843 This is a configuration pragma that defines a new implementation
1844 defined check name (unless IDENTIFIER matches one of the predefined
1845 check names, in which case the pragma has no effect). Check names
1846 are global to a partition, so if two or more configuration pragmas
1847 are present in a partition mentioning the same name, only one new
1848 check name is introduced.
1849
1850 An implementation defined check name introduced with this pragma may
1851 be used in only three contexts: @code{pragma Suppress},
1852 @code{pragma Unsuppress},
1853 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1854 any of these three cases, the check name must be visible. A check
1855 name is visible if it is in the configuration pragmas applying to
1856 the current unit, or if it appears at the start of any unit that
1857 is part of the dependency set of the current unit (e.g., units that
1858 are mentioned in @code{with} clauses).
1859
1860 Check names introduced by this pragma are subject to control by compiler
1861 switches (in particular -gnatp) in the usual manner.
1862
1863 @node Pragma Check_Policy
1864 @unnumberedsec Pragma Check_Policy
1865 @cindex Controlling assertions
1866 @cindex Assertions, control
1867 @cindex Check pragma control
1868 @cindex Named assertions
1869 @findex Check
1870 @noindent
1871 Syntax:
1872 @smallexample @c ada
1873 pragma Check_Policy
1874 ([Name =>] CHECK_KIND,
1875 [Policy =>] POLICY_IDENTIFIER);
1876
1877 pragma Check_Policy (
1878 CHECK_KIND => POLICY_IDENTIFIER
1879 @{, CHECK_KIND => POLICY_IDENTIFIER@});
1880
1881 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1882
1883 CHECK_KIND ::= IDENTIFIER |
1884 Pre'Class |
1885 Post'Class |
1886 Type_Invariant'Class |
1887 Invariant'Class
1888
1889 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1890 avoids confusion between the two possible syntax forms for this pragma.
1891
1892 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1893 @end smallexample
1894
1895 @noindent
1896 This pragma is used to set the checking policy for assertions (specified
1897 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1898 to be checked using the @code{Check} pragma. It may appear either as
1899 a configuration pragma, or within a declarative part of package. In the
1900 latter case, it applies from the point where it appears to the end of
1901 the declarative region (like pragma @code{Suppress}).
1902
1903 The @code{Check_Policy} pragma is similar to the
1904 predefined @code{Assertion_Policy} pragma,
1905 and if the check kind corresponds to one of the assertion kinds that
1906 are allowed by @code{Assertion_Policy}, then the effect is identical.
1907
1908 If the first argument is Debug, then the policy applies to Debug pragmas,
1909 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1910 @code{IGNORE}, and allowing them to execute with normal semantics if
1911 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1912 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1913 be totally ignored and not analyzed semantically.
1914
1915 Finally the first argument may be some other identifier than the above
1916 possibilities, in which case it controls a set of named assertions
1917 that can be checked using pragma @code{Check}. For example, if the pragma:
1918
1919 @smallexample @c ada
1920 pragma Check_Policy (Critical_Error, OFF);
1921 @end smallexample
1922
1923 @noindent
1924 is given, then subsequent @code{Check} pragmas whose first argument is also
1925 @code{Critical_Error} will be disabled.
1926
1927 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1928 to turn on corresponding checks. The default for a set of checks for which no
1929 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1930 @option{-gnata} is given, which turns on all checks by default.
1931
1932 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1933 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1934 compatibility with the standard @code{Assertion_Policy} pragma. The check
1935 policy setting @code{DISABLE} causes the second argument of a corresponding
1936 @code{Check} pragma to be completely ignored and not analyzed.
1937
1938 @node Pragma CIL_Constructor
1939 @unnumberedsec Pragma CIL_Constructor
1940 @findex CIL_Constructor
1941 @noindent
1942 Syntax:
1943
1944 @smallexample @c ada
1945 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1946 @end smallexample
1947
1948 @noindent
1949 This pragma is used to assert that the specified Ada function should be
1950 mapped to the .NET constructor for some Ada tagged record type.
1951
1952 See section 4.1 of the
1953 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1954 for related information.
1955
1956 @node Pragma Comment
1957 @unnumberedsec Pragma Comment
1958 @findex Comment
1959 @noindent
1960 Syntax:
1961
1962 @smallexample @c ada
1963 pragma Comment (static_string_EXPRESSION);
1964 @end smallexample
1965
1966 @noindent
1967 This is almost identical in effect to pragma @code{Ident}. It allows the
1968 placement of a comment into the object file and hence into the
1969 executable file if the operating system permits such usage. The
1970 difference is that @code{Comment}, unlike @code{Ident}, has
1971 no limitations on placement of the pragma (it can be placed
1972 anywhere in the main source unit), and if more than one pragma
1973 is used, all comments are retained.
1974
1975 @node Pragma Common_Object
1976 @unnumberedsec Pragma Common_Object
1977 @findex Common_Object
1978 @noindent
1979 Syntax:
1980
1981 @smallexample @c ada
1982 pragma Common_Object (
1983 [Internal =>] LOCAL_NAME
1984 [, [External =>] EXTERNAL_SYMBOL]
1985 [, [Size =>] EXTERNAL_SYMBOL] );
1986
1987 EXTERNAL_SYMBOL ::=
1988 IDENTIFIER
1989 | static_string_EXPRESSION
1990 @end smallexample
1991
1992 @noindent
1993 This pragma enables the shared use of variables stored in overlaid
1994 linker areas corresponding to the use of @code{COMMON}
1995 in Fortran. The single
1996 object @var{LOCAL_NAME} is assigned to the area designated by
1997 the @var{External} argument.
1998 You may define a record to correspond to a series
1999 of fields. The @var{Size} argument
2000 is syntax checked in GNAT, but otherwise ignored.
2001
2002 @code{Common_Object} is not supported on all platforms. If no
2003 support is available, then the code generator will issue a message
2004 indicating that the necessary attribute for implementation of this
2005 pragma is not available.
2006
2007 @node Pragma Compile_Time_Error
2008 @unnumberedsec Pragma Compile_Time_Error
2009 @findex Compile_Time_Error
2010 @noindent
2011 Syntax:
2012
2013 @smallexample @c ada
2014 pragma Compile_Time_Error
2015 (boolean_EXPRESSION, static_string_EXPRESSION);
2016 @end smallexample
2017
2018 @noindent
2019 This pragma can be used to generate additional compile time
2020 error messages. It
2021 is particularly useful in generics, where errors can be issued for
2022 specific problematic instantiations. The first parameter is a boolean
2023 expression. The pragma is effective only if the value of this expression
2024 is known at compile time, and has the value True. The set of expressions
2025 whose values are known at compile time includes all static boolean
2026 expressions, and also other values which the compiler can determine
2027 at compile time (e.g., the size of a record type set by an explicit
2028 size representation clause, or the value of a variable which was
2029 initialized to a constant and is known not to have been modified).
2030 If these conditions are met, an error message is generated using
2031 the value given as the second argument. This string value may contain
2032 embedded ASCII.LF characters to break the message into multiple lines.
2033
2034 @node Pragma Compile_Time_Warning
2035 @unnumberedsec Pragma Compile_Time_Warning
2036 @findex Compile_Time_Warning
2037 @noindent
2038 Syntax:
2039
2040 @smallexample @c ada
2041 pragma Compile_Time_Warning
2042 (boolean_EXPRESSION, static_string_EXPRESSION);
2043 @end smallexample
2044
2045 @noindent
2046 Same as pragma Compile_Time_Error, except a warning is issued instead
2047 of an error message. Note that if this pragma is used in a package that
2048 is with'ed by a client, the client will get the warning even though it
2049 is issued by a with'ed package (normally warnings in with'ed units are
2050 suppressed, but this is a special exception to that rule).
2051
2052 One typical use is within a generic where compile time known characteristics
2053 of formal parameters are tested, and warnings given appropriately. Another use
2054 with a first parameter of True is to warn a client about use of a package,
2055 for example that it is not fully implemented.
2056
2057 @node Pragma Compiler_Unit
2058 @unnumberedsec Pragma Compiler_Unit
2059 @findex Compiler_Unit
2060 @noindent
2061 Syntax:
2062
2063 @smallexample @c ada
2064 pragma Compiler_Unit;
2065 @end smallexample
2066
2067 @noindent
2068 This pragma is obsolete. It is equivalent to Compiler_Unit_Warning. It is
2069 retained so that old versions of the GNAT run-time that use this pragma can
2070 be compiled with newer versions of the compiler.
2071
2072 @node Pragma Compiler_Unit_Warning
2073 @unnumberedsec Pragma Compiler_Unit_Warning
2074 @findex Compiler_Unit_Warning
2075 @noindent
2076 Syntax:
2077
2078 @smallexample @c ada
2079 pragma Compiler_Unit_Warning;
2080 @end smallexample
2081
2082 @noindent
2083 This pragma is intended only for internal use in the GNAT run-time library.
2084 It indicates that the unit is used as part of the compiler build. The effect
2085 is to generate warnings for the use of constructs (for example, conditional
2086 expressions) that would cause trouble when bootstrapping using an older
2087 version of GNAT. For the exact list of restrictions, see the compiler sources
2088 and references to Check_Compiler_Unit.
2089
2090 @node Pragma Complete_Representation
2091 @unnumberedsec Pragma Complete_Representation
2092 @findex Complete_Representation
2093 @noindent
2094 Syntax:
2095
2096 @smallexample @c ada
2097 pragma Complete_Representation;
2098 @end smallexample
2099
2100 @noindent
2101 This pragma must appear immediately within a record representation
2102 clause. Typical placements are before the first component clause
2103 or after the last component clause. The effect is to give an error
2104 message if any component is missing a component clause. This pragma
2105 may be used to ensure that a record representation clause is
2106 complete, and that this invariant is maintained if fields are
2107 added to the record in the future.
2108
2109 @node Pragma Complex_Representation
2110 @unnumberedsec Pragma Complex_Representation
2111 @findex Complex_Representation
2112 @noindent
2113 Syntax:
2114
2115 @smallexample @c ada
2116 pragma Complex_Representation
2117 ([Entity =>] LOCAL_NAME);
2118 @end smallexample
2119
2120 @noindent
2121 The @var{Entity} argument must be the name of a record type which has
2122 two fields of the same floating-point type. The effect of this pragma is
2123 to force gcc to use the special internal complex representation form for
2124 this record, which may be more efficient. Note that this may result in
2125 the code for this type not conforming to standard ABI (application
2126 binary interface) requirements for the handling of record types. For
2127 example, in some environments, there is a requirement for passing
2128 records by pointer, and the use of this pragma may result in passing
2129 this type in floating-point registers.
2130
2131 @node Pragma Component_Alignment
2132 @unnumberedsec Pragma Component_Alignment
2133 @cindex Alignments of components
2134 @findex Component_Alignment
2135 @noindent
2136 Syntax:
2137
2138 @smallexample @c ada
2139 pragma Component_Alignment (
2140 [Form =>] ALIGNMENT_CHOICE
2141 [, [Name =>] type_LOCAL_NAME]);
2142
2143 ALIGNMENT_CHOICE ::=
2144 Component_Size
2145 | Component_Size_4
2146 | Storage_Unit
2147 | Default
2148 @end smallexample
2149
2150 @noindent
2151 Specifies the alignment of components in array or record types.
2152 The meaning of the @var{Form} argument is as follows:
2153
2154 @table @code
2155 @findex Component_Size
2156 @item Component_Size
2157 Aligns scalar components and subcomponents of the array or record type
2158 on boundaries appropriate to their inherent size (naturally
2159 aligned). For example, 1-byte components are aligned on byte boundaries,
2160 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2161 integer components are aligned on 4-byte boundaries and so on. These
2162 alignment rules correspond to the normal rules for C compilers on all
2163 machines except the VAX@.
2164
2165 @findex Component_Size_4
2166 @item Component_Size_4
2167 Naturally aligns components with a size of four or fewer
2168 bytes. Components that are larger than 4 bytes are placed on the next
2169 4-byte boundary.
2170
2171 @findex Storage_Unit
2172 @item Storage_Unit
2173 Specifies that array or record components are byte aligned, i.e.@:
2174 aligned on boundaries determined by the value of the constant
2175 @code{System.Storage_Unit}.
2176
2177 @cindex OpenVMS
2178 @item Default
2179 Specifies that array or record components are aligned on default
2180 boundaries, appropriate to the underlying hardware or operating system or
2181 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
2182 the @code{Storage_Unit} choice (byte alignment). For all other systems,
2183 the @code{Default} choice is the same as @code{Component_Size} (natural
2184 alignment).
2185 @end table
2186
2187 @noindent
2188 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2189 refer to a local record or array type, and the specified alignment
2190 choice applies to the specified type. The use of
2191 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2192 @code{Component_Alignment} pragma to be ignored. The use of
2193 @code{Component_Alignment} together with a record representation clause
2194 is only effective for fields not specified by the representation clause.
2195
2196 If the @code{Name} parameter is absent, the pragma can be used as either
2197 a configuration pragma, in which case it applies to one or more units in
2198 accordance with the normal rules for configuration pragmas, or it can be
2199 used within a declarative part, in which case it applies to types that
2200 are declared within this declarative part, or within any nested scope
2201 within this declarative part. In either case it specifies the alignment
2202 to be applied to any record or array type which has otherwise standard
2203 representation.
2204
2205 If the alignment for a record or array type is not specified (using
2206 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2207 clause), the GNAT uses the default alignment as described previously.
2208
2209 @node Pragma Contract_Cases
2210 @unnumberedsec Pragma Contract_Cases
2211 @cindex Contract cases
2212 @findex Contract_Cases
2213 @noindent
2214 Syntax:
2215
2216 @smallexample @c ada
2217 pragma Contract_Cases (
2218 Condition => Consequence
2219 @{,Condition => Consequence@});
2220 @end smallexample
2221
2222 @noindent
2223 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2224 that can complement or replace the contract given by a precondition and a
2225 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2226 by testing and formal verification tools. The compiler checks its validity and,
2227 depending on the assertion policy at the point of declaration of the pragma,
2228 it may insert a check in the executable. For code generation, the contract
2229 cases
2230
2231 @smallexample @c ada
2232 pragma Contract_Cases (
2233 Cond1 => Pred1,
2234 Cond2 => Pred2);
2235 @end smallexample
2236
2237 @noindent
2238 are equivalent to
2239
2240 @smallexample @c ada
2241 C1 : constant Boolean := Cond1; -- evaluated at subprogram entry
2242 C2 : constant Boolean := Cond2; -- evaluated at subprogram entry
2243 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2244 pragma Postcondition (if C1 then Pred1);
2245 pragma Postcondition (if C2 then Pred2);
2246 @end smallexample
2247
2248 @noindent
2249 The precondition ensures that one and only one of the conditions is
2250 satisfied on entry to the subprogram.
2251 The postcondition ensures that for the condition that was True on entry,
2252 the corrresponding consequence is True on exit. Other consequence expressions
2253 are not evaluated.
2254
2255 A precondition @code{P} and postcondition @code{Q} can also be
2256 expressed as contract cases:
2257
2258 @smallexample @c ada
2259 pragma Contract_Cases (P => Q);
2260 @end smallexample
2261
2262 The placement and visibility rules for @code{Contract_Cases} pragmas are
2263 identical to those described for preconditions and postconditions.
2264
2265 The compiler checks that boolean expressions given in conditions and
2266 consequences are valid, where the rules for conditions are the same as
2267 the rule for an expression in @code{Precondition} and the rules for
2268 consequences are the same as the rule for an expression in
2269 @code{Postcondition}. In particular, attributes @code{'Old} and
2270 @code{'Result} can only be used within consequence expressions.
2271 The condition for the last contract case may be @code{others}, to denote
2272 any case not captured by the previous cases. The
2273 following is an example of use within a package spec:
2274
2275 @smallexample @c ada
2276 package Math_Functions is
2277 ...
2278 function Sqrt (Arg : Float) return Float;
2279 pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2280 Arg >= 100 => Sqrt'Result >= 10,
2281 others => Sqrt'Result = 0);
2282 ...
2283 end Math_Functions;
2284 @end smallexample
2285
2286 @noindent
2287 The meaning of contract cases is that only one case should apply at each
2288 call, as determined by the corresponding condition evaluating to True,
2289 and that the consequence for this case should hold when the subprogram
2290 returns.
2291
2292 @node Pragma Convention_Identifier
2293 @unnumberedsec Pragma Convention_Identifier
2294 @findex Convention_Identifier
2295 @cindex Conventions, synonyms
2296 @noindent
2297 Syntax:
2298
2299 @smallexample @c ada
2300 pragma Convention_Identifier (
2301 [Name =>] IDENTIFIER,
2302 [Convention =>] convention_IDENTIFIER);
2303 @end smallexample
2304
2305 @noindent
2306 This pragma provides a mechanism for supplying synonyms for existing
2307 convention identifiers. The @code{Name} identifier can subsequently
2308 be used as a synonym for the given convention in other pragmas (including
2309 for example pragma @code{Import} or another @code{Convention_Identifier}
2310 pragma). As an example of the use of this, suppose you had legacy code
2311 which used Fortran77 as the identifier for Fortran. Then the pragma:
2312
2313 @smallexample @c ada
2314 pragma Convention_Identifier (Fortran77, Fortran);
2315 @end smallexample
2316
2317 @noindent
2318 would allow the use of the convention identifier @code{Fortran77} in
2319 subsequent code, avoiding the need to modify the sources. As another
2320 example, you could use this to parameterize convention requirements
2321 according to systems. Suppose you needed to use @code{Stdcall} on
2322 windows systems, and @code{C} on some other system, then you could
2323 define a convention identifier @code{Library} and use a single
2324 @code{Convention_Identifier} pragma to specify which convention
2325 would be used system-wide.
2326
2327 @node Pragma CPP_Class
2328 @unnumberedsec Pragma CPP_Class
2329 @findex CPP_Class
2330 @cindex Interfacing with C++
2331 @noindent
2332 Syntax:
2333
2334 @smallexample @c ada
2335 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2336 @end smallexample
2337
2338 @noindent
2339 The argument denotes an entity in the current declarative region that is
2340 declared as a record type. It indicates that the type corresponds to an
2341 externally declared C++ class type, and is to be laid out the same way
2342 that C++ would lay out the type. If the C++ class has virtual primitives
2343 then the record must be declared as a tagged record type.
2344
2345 Types for which @code{CPP_Class} is specified do not have assignment or
2346 equality operators defined (such operations can be imported or declared
2347 as subprograms as required). Initialization is allowed only by constructor
2348 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2349 limited if not explicitly declared as limited or derived from a limited
2350 type, and an error is issued in that case.
2351
2352 See @ref{Interfacing to C++} for related information.
2353
2354 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2355 for backward compatibility but its functionality is available
2356 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2357
2358 @node Pragma CPP_Constructor
2359 @unnumberedsec Pragma CPP_Constructor
2360 @cindex Interfacing with C++
2361 @findex CPP_Constructor
2362 @noindent
2363 Syntax:
2364
2365 @smallexample @c ada
2366 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2367 [, [External_Name =>] static_string_EXPRESSION ]
2368 [, [Link_Name =>] static_string_EXPRESSION ]);
2369 @end smallexample
2370
2371 @noindent
2372 This pragma identifies an imported function (imported in the usual way
2373 with pragma @code{Import}) as corresponding to a C++ constructor. If
2374 @code{External_Name} and @code{Link_Name} are not specified then the
2375 @code{Entity} argument is a name that must have been previously mentioned
2376 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2377 must be of one of the following forms:
2378
2379 @itemize @bullet
2380 @item
2381 @code{function @var{Fname} return @var{T}}
2382
2383 @itemize @bullet
2384 @item
2385 @code{function @var{Fname} return @var{T}'Class}
2386
2387 @item
2388 @code{function @var{Fname} (@dots{}) return @var{T}}
2389 @end itemize
2390
2391 @item
2392 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2393 @end itemize
2394
2395 @noindent
2396 where @var{T} is a limited record type imported from C++ with pragma
2397 @code{Import} and @code{Convention} = @code{CPP}.
2398
2399 The first two forms import the default constructor, used when an object
2400 of type @var{T} is created on the Ada side with no explicit constructor.
2401 The latter two forms cover all the non-default constructors of the type.
2402 See the @value{EDITION} User's Guide for details.
2403
2404 If no constructors are imported, it is impossible to create any objects
2405 on the Ada side and the type is implicitly declared abstract.
2406
2407 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2408 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2409 GCC switch).
2410 See @ref{Interfacing to C++} for more related information.
2411
2412 Note: The use of functions returning class-wide types for constructors is
2413 currently obsolete. They are supported for backward compatibility. The
2414 use of functions returning the type T leave the Ada sources more clear
2415 because the imported C++ constructors always return an object of type T;
2416 that is, they never return an object whose type is a descendant of type T.
2417
2418 @node Pragma CPP_Virtual
2419 @unnumberedsec Pragma CPP_Virtual
2420 @cindex Interfacing to C++
2421 @findex CPP_Virtual
2422 @noindent
2423 This pragma is now obsolete and, other than generating a warning if warnings
2424 on obsolescent features are enabled, is completely ignored.
2425 It is retained for compatibility
2426 purposes. It used to be required to ensure compoatibility with C++, but
2427 is no longer required for that purpose because GNAT generates
2428 the same object layout as the G++ compiler by default.
2429
2430 See @ref{Interfacing to C++} for related information.
2431
2432 @node Pragma CPP_Vtable
2433 @unnumberedsec Pragma CPP_Vtable
2434 @cindex Interfacing with C++
2435 @findex CPP_Vtable
2436 @noindent
2437 This pragma is now obsolete and, other than generating a warning if warnings
2438 on obsolescent features are enabled, is completely ignored.
2439 It used to be required to ensure compatibility with C++, but
2440 is no longer required for that purpose because GNAT generates
2441 the same object layout as the G++ compiler by default.
2442
2443 See @ref{Interfacing to C++} for related information.
2444
2445 @node Pragma CPU
2446 @unnumberedsec Pragma CPU
2447 @findex CPU
2448 @noindent
2449 Syntax:
2450
2451 @smallexample @c ada
2452 pragma CPU (EXPRESSION);
2453 @end smallexample
2454
2455 @noindent
2456 This pragma is standard in Ada 2012, but is available in all earlier
2457 versions of Ada as an implementation-defined pragma.
2458 See Ada 2012 Reference Manual for details.
2459
2460 @node Pragma Debug
2461 @unnumberedsec Pragma Debug
2462 @findex Debug
2463 @noindent
2464 Syntax:
2465
2466 @smallexample @c ada
2467 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2468
2469 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2470 PROCEDURE_NAME
2471 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2472 @end smallexample
2473
2474 @noindent
2475 The procedure call argument has the syntactic form of an expression, meeting
2476 the syntactic requirements for pragmas.
2477
2478 If debug pragmas are not enabled or if the condition is present and evaluates
2479 to False, this pragma has no effect. If debug pragmas are enabled, the
2480 semantics of the pragma is exactly equivalent to the procedure call statement
2481 corresponding to the argument with a terminating semicolon. Pragmas are
2482 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2483 intersperse calls to debug procedures in the middle of declarations. Debug
2484 pragmas can be enabled either by use of the command line switch @option{-gnata}
2485 or by use of the pragma @code{Check_Policy} with a first argument of
2486 @code{Debug}.
2487
2488 @node Pragma Debug_Policy
2489 @unnumberedsec Pragma Debug_Policy
2490 @findex Debug_Policy
2491 @noindent
2492 Syntax:
2493
2494 @smallexample @c ada
2495 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2496 @end smallexample
2497
2498 @noindent
2499 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2500 with a first argument of @code{Debug}. It is retained for historical
2501 compatibility reasons.
2502
2503 @node Pragma Default_Storage_Pool
2504 @unnumberedsec Pragma Default_Storage_Pool
2505 @findex Default_Storage_Pool
2506 @noindent
2507 Syntax:
2508
2509 @smallexample @c ada
2510 pragma Default_Storage_Pool (storage_pool_NAME | null);
2511 @end smallexample
2512
2513 @noindent
2514 This pragma is standard in Ada 2012, but is available in all earlier
2515 versions of Ada as an implementation-defined pragma.
2516 See Ada 2012 Reference Manual for details.
2517
2518 @node Pragma Depends
2519 @unnumberedsec Pragma Depends
2520 @findex Depends
2521 @noindent
2522 For the description of this pragma, see SPARK 2014 Reference Manual,
2523 section 6.1.5.
2524
2525 @node Pragma Detect_Blocking
2526 @unnumberedsec Pragma Detect_Blocking
2527 @findex Detect_Blocking
2528 @noindent
2529 Syntax:
2530
2531 @smallexample @c ada
2532 pragma Detect_Blocking;
2533 @end smallexample
2534
2535 @noindent
2536 This is a standard pragma in Ada 2005, that is available in all earlier
2537 versions of Ada as an implementation-defined pragma.
2538
2539 This is a configuration pragma that forces the detection of potentially
2540 blocking operations within a protected operation, and to raise Program_Error
2541 if that happens.
2542
2543 @node Pragma Disable_Atomic_Synchronization
2544 @unnumberedsec Pragma Disable_Atomic_Synchronization
2545 @cindex Atomic Synchronization
2546 @findex Disable_Atomic_Synchronization
2547 @noindent
2548 Syntax:
2549
2550 @smallexample @c ada
2551 pragma Disable_Atomic_Synchronization [(Entity)];
2552 @end smallexample
2553
2554 @noindent
2555 Ada requires that accesses (reads or writes) of an atomic variable be
2556 regarded as synchronization points in the case of multiple tasks.
2557 Particularly in the case of multi-processors this may require special
2558 handling, e.g. the generation of memory barriers. This capability may
2559 be turned off using this pragma in cases where it is known not to be
2560 required.
2561
2562 The placement and scope rules for this pragma are the same as those
2563 for @code{pragma Suppress}. In particular it can be used as a
2564 configuration pragma, or in a declaration sequence where it applies
2565 till the end of the scope. If an @code{Entity} argument is present,
2566 the action applies only to that entity.
2567
2568 @node Pragma Dispatching_Domain
2569 @unnumberedsec Pragma Dispatching_Domain
2570 @findex Dispatching_Domain
2571 @noindent
2572 Syntax:
2573
2574 @smallexample @c ada
2575 pragma Dispatching_Domain (EXPRESSION);
2576 @end smallexample
2577
2578 @noindent
2579 This pragma is standard in Ada 2012, but is available in all earlier
2580 versions of Ada as an implementation-defined pragma.
2581 See Ada 2012 Reference Manual for details.
2582
2583 @node Pragma Effective_Reads
2584 @unnumberedsec Pragma Effective_Reads
2585 @findex Effective_Reads
2586 @noindent
2587 For the description of this pragma, see SPARK 2014 Reference Manual,
2588 section 7.1.2.
2589
2590 @node Pragma Effective_Writes
2591 @unnumberedsec Pragma Effective_Writes
2592 @findex Effective_Writes
2593 @noindent
2594 For the description of this pragma, see SPARK 2014 Reference Manual,
2595 section 7.1.2.
2596
2597 @node Pragma Elaboration_Checks
2598 @unnumberedsec Pragma Elaboration_Checks
2599 @cindex Elaboration control
2600 @findex Elaboration_Checks
2601 @noindent
2602 Syntax:
2603
2604 @smallexample @c ada
2605 pragma Elaboration_Checks (Dynamic | Static);
2606 @end smallexample
2607
2608 @noindent
2609 This is a configuration pragma that provides control over the
2610 elaboration model used by the compilation affected by the
2611 pragma. If the parameter is @code{Dynamic},
2612 then the dynamic elaboration
2613 model described in the Ada Reference Manual is used, as though
2614 the @option{-gnatE} switch had been specified on the command
2615 line. If the parameter is @code{Static}, then the default GNAT static
2616 model is used. This configuration pragma overrides the setting
2617 of the command line. For full details on the elaboration models
2618 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2619 gnat_ugn, @value{EDITION} User's Guide}.
2620
2621 @node Pragma Eliminate
2622 @unnumberedsec Pragma Eliminate
2623 @cindex Elimination of unused subprograms
2624 @findex Eliminate
2625 @noindent
2626 Syntax:
2627
2628 @smallexample @c ada
2629 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2630 [Source_Location =>] STRING_LITERAL);
2631 @end smallexample
2632
2633 @noindent
2634 The string literal given for the source location is a string which
2635 specifies the line number of the occurrence of the entity, using
2636 the syntax for SOURCE_TRACE given below:
2637
2638 @smallexample @c ada
2639 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2640
2641 LBRACKET ::= [
2642 RBRACKET ::= ]
2643
2644 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2645
2646 LINE_NUMBER ::= DIGIT @{DIGIT@}
2647 @end smallexample
2648
2649 @noindent
2650 Spaces around the colon in a @code{Source_Reference} are optional.
2651
2652 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2653 explicit subprogram declaration, where the @code{entity} name in this
2654 designator appears on the source line specified by the source location.
2655
2656 The source trace that is given as the @code{Source_Location} shall obey the
2657 following rules. The @code{FILE_NAME} is the short name (with no directory
2658 information) of an Ada source file, given using exactly the required syntax
2659 for the underlying file system (e.g. case is important if the underlying
2660 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2661 number of the occurrence of the @code{entity}
2662 as a decimal literal without an exponent or point. If an @code{entity} is not
2663 declared in a generic instantiation (this includes generic subprogram
2664 instances), the source trace includes only one source reference. If an entity
2665 is declared inside a generic instantiation, its source trace (when parsing
2666 from left to right) starts with the source location of the declaration of the
2667 entity in the generic unit and ends with the source location of the
2668 instantiation (it is given in square brackets). This approach is recursively
2669 used in case of nested instantiations: the rightmost (nested most deeply in
2670 square brackets) element of the source trace is the location of the outermost
2671 instantiation, the next to left element is the location of the next (first
2672 nested) instantiation in the code of the corresponding generic unit, and so
2673 on, and the leftmost element (that is out of any square brackets) is the
2674 location of the declaration of the entity to eliminate in a generic unit.
2675
2676 Note that the @code{Source_Location} argument specifies which of a set of
2677 similarly named entities is being eliminated, dealing both with overloading,
2678 and also appearance of the same entity name in different scopes.
2679
2680 This pragma indicates that the given entity is not used in the program to be
2681 compiled and built. The effect of the pragma is to allow the compiler to
2682 eliminate the code or data associated with the named entity. Any reference to
2683 an eliminated entity causes a compile-time or link-time error.
2684
2685 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2686 in a system-independent manner, with unused entities eliminated, without
2687 needing to modify the source text. Normally the required set of
2688 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2689
2690 Any source file change that removes, splits, or
2691 adds lines may make the set of Eliminate pragmas invalid because their
2692 @code{Source_Location} argument values may get out of date.
2693
2694 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2695 operation. In this case all the subprograms to which the given operation can
2696 dispatch are considered to be unused (are never called as a result of a direct
2697 or a dispatching call).
2698
2699 @node Pragma Enable_Atomic_Synchronization
2700 @unnumberedsec Pragma Enable_Atomic_Synchronization
2701 @cindex Atomic Synchronization
2702 @findex Enable_Atomic_Synchronization
2703 @noindent
2704 Syntax:
2705
2706 @smallexample @c ada
2707 pragma Enable_Atomic_Synchronization [(Entity)];
2708 @end smallexample
2709
2710 @noindent
2711 Ada requires that accesses (reads or writes) of an atomic variable be
2712 regarded as synchronization points in the case of multiple tasks.
2713 Particularly in the case of multi-processors this may require special
2714 handling, e.g. the generation of memory barriers. This synchronization
2715 is performed by default, but can be turned off using
2716 @code{pragma Disable_Atomic_Synchronization}. The
2717 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2718 it back on.
2719
2720 The placement and scope rules for this pragma are the same as those
2721 for @code{pragma Unsuppress}. In particular it can be used as a
2722 configuration pragma, or in a declaration sequence where it applies
2723 till the end of the scope. If an @code{Entity} argument is present,
2724 the action applies only to that entity.
2725
2726 @node Pragma Export_Exception
2727 @unnumberedsec Pragma Export_Exception
2728 @cindex OpenVMS
2729 @findex Export_Exception
2730 @noindent
2731 Syntax:
2732
2733 @smallexample @c ada
2734 pragma Export_Exception (
2735 [Internal =>] LOCAL_NAME
2736 [, [External =>] EXTERNAL_SYMBOL]
2737 [, [Form =>] Ada | VMS]
2738 [, [Code =>] static_integer_EXPRESSION]);
2739
2740 EXTERNAL_SYMBOL ::=
2741 IDENTIFIER
2742 | static_string_EXPRESSION
2743 @end smallexample
2744
2745 @noindent
2746 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2747 causes the specified exception to be propagated outside of the Ada program,
2748 so that it can be handled by programs written in other OpenVMS languages.
2749 This pragma establishes an external name for an Ada exception and makes the
2750 name available to the OpenVMS Linker as a global symbol. For further details
2751 on this pragma, see the
2752 DEC Ada Language Reference Manual, section 13.9a3.2.
2753
2754 @node Pragma Export_Function
2755 @unnumberedsec Pragma Export_Function
2756 @cindex Argument passing mechanisms
2757 @findex Export_Function
2758
2759 @noindent
2760 Syntax:
2761
2762 @smallexample @c ada
2763 pragma Export_Function (
2764 [Internal =>] LOCAL_NAME
2765 [, [External =>] EXTERNAL_SYMBOL]
2766 [, [Parameter_Types =>] PARAMETER_TYPES]
2767 [, [Result_Type =>] result_SUBTYPE_MARK]
2768 [, [Mechanism =>] MECHANISM]
2769 [, [Result_Mechanism =>] MECHANISM_NAME]);
2770
2771 EXTERNAL_SYMBOL ::=
2772 IDENTIFIER
2773 | static_string_EXPRESSION
2774 | ""
2775
2776 PARAMETER_TYPES ::=
2777 null
2778 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2779
2780 TYPE_DESIGNATOR ::=
2781 subtype_NAME
2782 | subtype_Name ' Access
2783
2784 MECHANISM ::=
2785 MECHANISM_NAME
2786 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2787
2788 MECHANISM_ASSOCIATION ::=
2789 [formal_parameter_NAME =>] MECHANISM_NAME
2790
2791 MECHANISM_NAME ::=
2792 Value
2793 | Reference
2794 | Descriptor [([Class =>] CLASS_NAME)]
2795 | Short_Descriptor [([Class =>] CLASS_NAME)]
2796
2797 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2798 @end smallexample
2799
2800 @noindent
2801 Use this pragma to make a function externally callable and optionally
2802 provide information on mechanisms to be used for passing parameter and
2803 result values. We recommend, for the purposes of improving portability,
2804 this pragma always be used in conjunction with a separate pragma
2805 @code{Export}, which must precede the pragma @code{Export_Function}.
2806 GNAT does not require a separate pragma @code{Export}, but if none is
2807 present, @code{Convention Ada} is assumed, which is usually
2808 not what is wanted, so it is usually appropriate to use this
2809 pragma in conjunction with a @code{Export} or @code{Convention}
2810 pragma that specifies the desired foreign convention.
2811 Pragma @code{Export_Function}
2812 (and @code{Export}, if present) must appear in the same declarative
2813 region as the function to which they apply.
2814
2815 @var{internal_name} must uniquely designate the function to which the
2816 pragma applies. If more than one function name exists of this name in
2817 the declarative part you must use the @code{Parameter_Types} and
2818 @code{Result_Type} parameters is mandatory to achieve the required
2819 unique designation. @var{subtype_mark}s in these parameters must
2820 exactly match the subtypes in the corresponding function specification,
2821 using positional notation to match parameters with subtype marks.
2822 The form with an @code{'Access} attribute can be used to match an
2823 anonymous access parameter.
2824
2825 @cindex OpenVMS
2826 @cindex Passing by descriptor
2827 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2828 The default behavior for Export_Function is to accept either 64bit or
2829 32bit descriptors unless short_descriptor is specified, then only 32bit
2830 descriptors are accepted.
2831
2832 @cindex Suppressing external name
2833 Special treatment is given if the EXTERNAL is an explicit null
2834 string or a static string expressions that evaluates to the null
2835 string. In this case, no external name is generated. This form
2836 still allows the specification of parameter mechanisms.
2837
2838 @node Pragma Export_Object
2839 @unnumberedsec Pragma Export_Object
2840 @findex Export_Object
2841 @noindent
2842 Syntax:
2843
2844 @smallexample @c ada
2845 pragma Export_Object
2846 [Internal =>] LOCAL_NAME
2847 [, [External =>] EXTERNAL_SYMBOL]
2848 [, [Size =>] EXTERNAL_SYMBOL]
2849
2850 EXTERNAL_SYMBOL ::=
2851 IDENTIFIER
2852 | static_string_EXPRESSION
2853 @end smallexample
2854
2855 @noindent
2856 This pragma designates an object as exported, and apart from the
2857 extended rules for external symbols, is identical in effect to the use of
2858 the normal @code{Export} pragma applied to an object. You may use a
2859 separate Export pragma (and you probably should from the point of view
2860 of portability), but it is not required. @var{Size} is syntax checked,
2861 but otherwise ignored by GNAT@.
2862
2863 @node Pragma Export_Procedure
2864 @unnumberedsec Pragma Export_Procedure
2865 @findex Export_Procedure
2866 @noindent
2867 Syntax:
2868
2869 @smallexample @c ada
2870 pragma Export_Procedure (
2871 [Internal =>] LOCAL_NAME
2872 [, [External =>] EXTERNAL_SYMBOL]
2873 [, [Parameter_Types =>] PARAMETER_TYPES]
2874 [, [Mechanism =>] MECHANISM]);
2875
2876 EXTERNAL_SYMBOL ::=
2877 IDENTIFIER
2878 | static_string_EXPRESSION
2879 | ""
2880
2881 PARAMETER_TYPES ::=
2882 null
2883 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2884
2885 TYPE_DESIGNATOR ::=
2886 subtype_NAME
2887 | subtype_Name ' Access
2888
2889 MECHANISM ::=
2890 MECHANISM_NAME
2891 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2892
2893 MECHANISM_ASSOCIATION ::=
2894 [formal_parameter_NAME =>] MECHANISM_NAME
2895
2896 MECHANISM_NAME ::=
2897 Value
2898 | Reference
2899 | Descriptor [([Class =>] CLASS_NAME)]
2900 | Short_Descriptor [([Class =>] CLASS_NAME)]
2901
2902 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2903 @end smallexample
2904
2905 @noindent
2906 This pragma is identical to @code{Export_Function} except that it
2907 applies to a procedure rather than a function and the parameters
2908 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2909 GNAT does not require a separate pragma @code{Export}, but if none is
2910 present, @code{Convention Ada} is assumed, which is usually
2911 not what is wanted, so it is usually appropriate to use this
2912 pragma in conjunction with a @code{Export} or @code{Convention}
2913 pragma that specifies the desired foreign convention.
2914
2915 @cindex OpenVMS
2916 @cindex Passing by descriptor
2917 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2918 The default behavior for Export_Procedure is to accept either 64bit or
2919 32bit descriptors unless short_descriptor is specified, then only 32bit
2920 descriptors are accepted.
2921
2922 @cindex Suppressing external name
2923 Special treatment is given if the EXTERNAL is an explicit null
2924 string or a static string expressions that evaluates to the null
2925 string. In this case, no external name is generated. This form
2926 still allows the specification of parameter mechanisms.
2927
2928 @node Pragma Export_Value
2929 @unnumberedsec Pragma Export_Value
2930 @findex Export_Value
2931 @noindent
2932 Syntax:
2933
2934 @smallexample @c ada
2935 pragma Export_Value (
2936 [Value =>] static_integer_EXPRESSION,
2937 [Link_Name =>] static_string_EXPRESSION);
2938 @end smallexample
2939
2940 @noindent
2941 This pragma serves to export a static integer value for external use.
2942 The first argument specifies the value to be exported. The Link_Name
2943 argument specifies the symbolic name to be associated with the integer
2944 value. This pragma is useful for defining a named static value in Ada
2945 that can be referenced in assembly language units to be linked with
2946 the application. This pragma is currently supported only for the
2947 AAMP target and is ignored for other targets.
2948
2949 @node Pragma Export_Valued_Procedure
2950 @unnumberedsec Pragma Export_Valued_Procedure
2951 @findex Export_Valued_Procedure
2952 @noindent
2953 Syntax:
2954
2955 @smallexample @c ada
2956 pragma Export_Valued_Procedure (
2957 [Internal =>] LOCAL_NAME
2958 [, [External =>] EXTERNAL_SYMBOL]
2959 [, [Parameter_Types =>] PARAMETER_TYPES]
2960 [, [Mechanism =>] MECHANISM]);
2961
2962 EXTERNAL_SYMBOL ::=
2963 IDENTIFIER
2964 | static_string_EXPRESSION
2965 | ""
2966
2967 PARAMETER_TYPES ::=
2968 null
2969 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2970
2971 TYPE_DESIGNATOR ::=
2972 subtype_NAME
2973 | subtype_Name ' Access
2974
2975 MECHANISM ::=
2976 MECHANISM_NAME
2977 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2978
2979 MECHANISM_ASSOCIATION ::=
2980 [formal_parameter_NAME =>] MECHANISM_NAME
2981
2982 MECHANISM_NAME ::=
2983 Value
2984 | Reference
2985 | Descriptor [([Class =>] CLASS_NAME)]
2986 | Short_Descriptor [([Class =>] CLASS_NAME)]
2987
2988 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2989 @end smallexample
2990
2991 @noindent
2992 This pragma is identical to @code{Export_Procedure} except that the
2993 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2994 mode @code{OUT}, and externally the subprogram is treated as a function
2995 with this parameter as the result of the function. GNAT provides for
2996 this capability to allow the use of @code{OUT} and @code{IN OUT}
2997 parameters in interfacing to external functions (which are not permitted
2998 in Ada functions).
2999 GNAT does not require a separate pragma @code{Export}, but if none is
3000 present, @code{Convention Ada} is assumed, which is almost certainly
3001 not what is wanted since the whole point of this pragma is to interface
3002 with foreign language functions, so it is usually appropriate to use this
3003 pragma in conjunction with a @code{Export} or @code{Convention}
3004 pragma that specifies the desired foreign convention.
3005
3006 @cindex OpenVMS
3007 @cindex Passing by descriptor
3008 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3009 The default behavior for Export_Valued_Procedure is to accept either 64bit or
3010 32bit descriptors unless short_descriptor is specified, then only 32bit
3011 descriptors are accepted.
3012
3013 @cindex Suppressing external name
3014 Special treatment is given if the EXTERNAL is an explicit null
3015 string or a static string expressions that evaluates to the null
3016 string. In this case, no external name is generated. This form
3017 still allows the specification of parameter mechanisms.
3018
3019 @node Pragma Extend_System
3020 @unnumberedsec Pragma Extend_System
3021 @cindex @code{system}, extending
3022 @cindex Dec Ada 83
3023 @findex Extend_System
3024 @noindent
3025 Syntax:
3026
3027 @smallexample @c ada
3028 pragma Extend_System ([Name =>] IDENTIFIER);
3029 @end smallexample
3030
3031 @noindent
3032 This pragma is used to provide backwards compatibility with other
3033 implementations that extend the facilities of package @code{System}. In
3034 GNAT, @code{System} contains only the definitions that are present in
3035 the Ada RM@. However, other implementations, notably the DEC Ada 83
3036 implementation, provide many extensions to package @code{System}.
3037
3038 For each such implementation accommodated by this pragma, GNAT provides a
3039 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
3040 implementation, which provides the required additional definitions. You
3041 can use this package in two ways. You can @code{with} it in the normal
3042 way and access entities either by selection or using a @code{use}
3043 clause. In this case no special processing is required.
3044
3045 However, if existing code contains references such as
3046 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
3047 definitions provided in package @code{System}, you may use this pragma
3048 to extend visibility in @code{System} in a non-standard way that
3049 provides greater compatibility with the existing code. Pragma
3050 @code{Extend_System} is a configuration pragma whose single argument is
3051 the name of the package containing the extended definition
3052 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
3053 control of this pragma will be processed using special visibility
3054 processing that looks in package @code{System.Aux_@var{xxx}} where
3055 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
3056 package @code{System}, but not found in package @code{System}.
3057
3058 You can use this pragma either to access a predefined @code{System}
3059 extension supplied with the compiler, for example @code{Aux_DEC} or
3060 you can construct your own extension unit following the above
3061 definition. Note that such a package is a child of @code{System}
3062 and thus is considered part of the implementation.
3063 To compile it you will have to use the @option{-gnatg} switch,
3064 or the @option{/GNAT_INTERNAL} qualifier on OpenVMS,
3065 for compiling System units, as explained in the
3066 @value{EDITION} User's Guide.
3067
3068 @node Pragma Extensions_Allowed
3069 @unnumberedsec Pragma Extensions_Allowed
3070 @cindex Ada Extensions
3071 @cindex GNAT Extensions
3072 @findex Extensions_Allowed
3073 @noindent
3074 Syntax:
3075
3076 @smallexample @c ada
3077 pragma Extensions_Allowed (On | Off);
3078 @end smallexample
3079
3080 @noindent
3081 This configuration pragma enables or disables the implementation
3082 extension mode (the use of Off as a parameter cancels the effect
3083 of the @option{-gnatX} command switch).
3084
3085 In extension mode, the latest version of the Ada language is
3086 implemented (currently Ada 2012), and in addition a small number
3087 of GNAT specific extensions are recognized as follows:
3088
3089 @table @asis
3090 @item Constrained attribute for generic objects
3091 The @code{Constrained} attribute is permitted for objects of
3092 generic types. The result indicates if the corresponding actual
3093 is constrained.
3094
3095 @end table
3096
3097 @node Pragma External
3098 @unnumberedsec Pragma External
3099 @findex External
3100 @noindent
3101 Syntax:
3102
3103 @smallexample @c ada
3104 pragma External (
3105 [ Convention =>] convention_IDENTIFIER,
3106 [ Entity =>] LOCAL_NAME
3107 [, [External_Name =>] static_string_EXPRESSION ]
3108 [, [Link_Name =>] static_string_EXPRESSION ]);
3109 @end smallexample
3110
3111 @noindent
3112 This pragma is identical in syntax and semantics to pragma
3113 @code{Export} as defined in the Ada Reference Manual. It is
3114 provided for compatibility with some Ada 83 compilers that
3115 used this pragma for exactly the same purposes as pragma
3116 @code{Export} before the latter was standardized.
3117
3118 @node Pragma External_Name_Casing
3119 @unnumberedsec Pragma External_Name_Casing
3120 @cindex Dec Ada 83 casing compatibility
3121 @cindex External Names, casing
3122 @cindex Casing of External names
3123 @findex External_Name_Casing
3124 @noindent
3125 Syntax:
3126
3127 @smallexample @c ada
3128 pragma External_Name_Casing (
3129 Uppercase | Lowercase
3130 [, Uppercase | Lowercase | As_Is]);
3131 @end smallexample
3132
3133 @noindent
3134 This pragma provides control over the casing of external names associated
3135 with Import and Export pragmas. There are two cases to consider:
3136
3137 @table @asis
3138 @item Implicit external names
3139 Implicit external names are derived from identifiers. The most common case
3140 arises when a standard Ada Import or Export pragma is used with only two
3141 arguments, as in:
3142
3143 @smallexample @c ada
3144 pragma Import (C, C_Routine);
3145 @end smallexample
3146
3147 @noindent
3148 Since Ada is a case-insensitive language, the spelling of the identifier in
3149 the Ada source program does not provide any information on the desired
3150 casing of the external name, and so a convention is needed. In GNAT the
3151 default treatment is that such names are converted to all lower case
3152 letters. This corresponds to the normal C style in many environments.
3153 The first argument of pragma @code{External_Name_Casing} can be used to
3154 control this treatment. If @code{Uppercase} is specified, then the name
3155 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3156 then the normal default of all lower case letters will be used.
3157
3158 This same implicit treatment is also used in the case of extended DEC Ada 83
3159 compatible Import and Export pragmas where an external name is explicitly
3160 specified using an identifier rather than a string.
3161
3162 @item Explicit external names
3163 Explicit external names are given as string literals. The most common case
3164 arises when a standard Ada Import or Export pragma is used with three
3165 arguments, as in:
3166
3167 @smallexample @c ada
3168 pragma Import (C, C_Routine, "C_routine");
3169 @end smallexample
3170
3171 @noindent
3172 In this case, the string literal normally provides the exact casing required
3173 for the external name. The second argument of pragma
3174 @code{External_Name_Casing} may be used to modify this behavior.
3175 If @code{Uppercase} is specified, then the name
3176 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3177 then the name will be forced to all lowercase letters. A specification of
3178 @code{As_Is} provides the normal default behavior in which the casing is
3179 taken from the string provided.
3180 @end table
3181
3182 @noindent
3183 This pragma may appear anywhere that a pragma is valid. In particular, it
3184 can be used as a configuration pragma in the @file{gnat.adc} file, in which
3185 case it applies to all subsequent compilations, or it can be used as a program
3186 unit pragma, in which case it only applies to the current unit, or it can
3187 be used more locally to control individual Import/Export pragmas.
3188
3189 It is primarily intended for use with OpenVMS systems, where many
3190 compilers convert all symbols to upper case by default. For interfacing to
3191 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3192 the pragma:
3193
3194 @smallexample @c ada
3195 pragma External_Name_Casing (Uppercase, Uppercase);
3196 @end smallexample
3197
3198 @noindent
3199 to enforce the upper casing of all external symbols.
3200
3201 @node Pragma Fast_Math
3202 @unnumberedsec Pragma Fast_Math
3203 @findex Fast_Math
3204 @noindent
3205 Syntax:
3206
3207 @smallexample @c ada
3208 pragma Fast_Math;
3209 @end smallexample
3210
3211 @noindent
3212 This is a configuration pragma which activates a mode in which speed is
3213 considered more important for floating-point operations than absolutely
3214 accurate adherence to the requirements of the standard. Currently the
3215 following operations are affected:
3216
3217 @table @asis
3218 @item Complex Multiplication
3219 The normal simple formula for complex multiplication can result in intermediate
3220 overflows for numbers near the end of the range. The Ada standard requires that
3221 this situation be detected and corrected by scaling, but in Fast_Math mode such
3222 cases will simply result in overflow. Note that to take advantage of this you
3223 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3224 under control of the pragma, rather than use the preinstantiated versions.
3225 @end table
3226
3227 @node Pragma Favor_Top_Level
3228 @unnumberedsec Pragma Favor_Top_Level
3229 @findex Favor_Top_Level
3230 @noindent
3231 Syntax:
3232
3233 @smallexample @c ada
3234 pragma Favor_Top_Level (type_NAME);
3235 @end smallexample
3236
3237 @noindent
3238 The named type must be an access-to-subprogram type. This pragma is an
3239 efficiency hint to the compiler, regarding the use of 'Access or
3240 'Unrestricted_Access on nested (non-library-level) subprograms. The
3241 pragma means that nested subprograms are not used with this type, or
3242 are rare, so that the generated code should be efficient in the
3243 top-level case. When this pragma is used, dynamically generated
3244 trampolines may be used on some targets for nested subprograms.
3245 See also the No_Implicit_Dynamic_Code restriction.
3246
3247 @node Pragma Finalize_Storage_Only
3248 @unnumberedsec Pragma Finalize_Storage_Only
3249 @findex Finalize_Storage_Only
3250 @noindent
3251 Syntax:
3252
3253 @smallexample @c ada
3254 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3255 @end smallexample
3256
3257 @noindent
3258 This pragma allows the compiler not to emit a Finalize call for objects
3259 defined at the library level. This is mostly useful for types where
3260 finalization is only used to deal with storage reclamation since in most
3261 environments it is not necessary to reclaim memory just before terminating
3262 execution, hence the name.
3263
3264 @node Pragma Float_Representation
3265 @unnumberedsec Pragma Float_Representation
3266 @cindex OpenVMS
3267 @findex Float_Representation
3268 @noindent
3269 Syntax:
3270
3271 @smallexample @c ada
3272 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3273
3274 FLOAT_REP ::= VAX_Float | IEEE_Float
3275 @end smallexample
3276
3277 @noindent
3278 In the one argument form, this pragma is a configuration pragma which
3279 allows control over the internal representation chosen for the predefined
3280 floating point types declared in the packages @code{Standard} and
3281 @code{System}. On all systems other than OpenVMS, the argument must
3282 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3283 argument may be @code{VAX_Float} to specify the use of the VAX float
3284 format for the floating-point types in Standard. This requires that
3285 the standard runtime libraries be recompiled.
3286
3287 The two argument form specifies the representation to be used for
3288 the specified floating-point type. On all systems other than OpenVMS,
3289 the argument must
3290 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3291
3292 @itemize @bullet
3293 @item
3294 For a digits value of 6, 32-bit IEEE short format will be used.
3295 @item
3296 For a digits value of 15, 64-bit IEEE long format will be used.
3297 @item
3298 No other value of digits is permitted.
3299 @end itemize
3300
3301 On OpenVMS, the
3302 argument may be @code{VAX_Float} to specify the use of the VAX float
3303 format, as follows:
3304
3305 @itemize @bullet
3306 @item
3307 For digits values up to 6, F float format will be used.
3308 @item
3309 For digits values from 7 to 9, D float format will be used.
3310 @item
3311 For digits values from 10 to 15, G float format will be used.
3312 @item
3313 Digits values above 15 are not allowed.
3314 @end itemize
3315
3316 @node Pragma Global
3317 @unnumberedsec Pragma Global
3318 @findex Global
3319 @noindent
3320 For the description of this pragma, see SPARK 2014 Reference Manual,
3321 section 6.1.4.
3322
3323 @node Pragma Ident
3324 @unnumberedsec Pragma Ident
3325 @findex Ident
3326 @noindent
3327 Syntax:
3328
3329 @smallexample @c ada
3330 pragma Ident (static_string_EXPRESSION);
3331 @end smallexample
3332
3333 @noindent
3334 This pragma provides a string identification in the generated object file,
3335 if the system supports the concept of this kind of identification string.
3336 This pragma is allowed only in the outermost declarative part or
3337 declarative items of a compilation unit. If more than one @code{Ident}
3338 pragma is given, only the last one processed is effective.
3339 @cindex OpenVMS
3340 On OpenVMS systems, the effect of the pragma is identical to the effect of
3341 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
3342 maximum allowed length is 31 characters, so if it is important to
3343 maintain compatibility with this compiler, you should obey this length
3344 limit.
3345
3346 @node Pragma Implementation_Defined
3347 @unnumberedsec Pragma Implementation_Defined
3348 @findex Implementation_Defined
3349 @noindent
3350 Syntax:
3351
3352 @smallexample @c ada
3353 pragma Implementation_Defined (local_NAME);
3354 @end smallexample
3355
3356 @noindent
3357 This pragma marks a previously declared entioty as implementation-defined.
3358 For an overloaded entity, applies to the most recent homonym.
3359
3360 @smallexample @c ada
3361 pragma Implementation_Defined;
3362 @end smallexample
3363
3364 @noindent
3365 The form with no arguments appears anywhere within a scope, most
3366 typically a package spec, and indicates that all entities that are
3367 defined within the package spec are Implementation_Defined.
3368
3369 This pragma is used within the GNAT runtime library to identify
3370 implementation-defined entities introduced in language-defined units,
3371 for the purpose of implementing the No_Implementation_Identifiers
3372 restriction.
3373
3374 @node Pragma Implemented
3375 @unnumberedsec Pragma Implemented
3376 @findex Implemented
3377 @noindent
3378 Syntax:
3379
3380 @smallexample @c ada
3381 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3382
3383 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3384 @end smallexample
3385
3386 @noindent
3387 This is an Ada 2012 representation pragma which applies to protected, task
3388 and synchronized interface primitives. The use of pragma Implemented provides
3389 a way to impose a static requirement on the overriding operation by adhering
3390 to one of the three implementation kinds: entry, protected procedure or any of
3391 the above. This pragma is available in all earlier versions of Ada as an
3392 implementation-defined pragma.
3393
3394 @smallexample @c ada
3395 type Synch_Iface is synchronized interface;
3396 procedure Prim_Op (Obj : in out Iface) is abstract;
3397 pragma Implemented (Prim_Op, By_Protected_Procedure);
3398
3399 protected type Prot_1 is new Synch_Iface with
3400 procedure Prim_Op; -- Legal
3401 end Prot_1;
3402
3403 protected type Prot_2 is new Synch_Iface with
3404 entry Prim_Op; -- Illegal
3405 end Prot_2;
3406
3407 task type Task_Typ is new Synch_Iface with
3408 entry Prim_Op; -- Illegal
3409 end Task_Typ;
3410 @end smallexample
3411
3412 @noindent
3413 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3414 Implemented determines the runtime behavior of the requeue. Implementation kind
3415 By_Entry guarantees that the action of requeueing will proceed from an entry to
3416 another entry. Implementation kind By_Protected_Procedure transforms the
3417 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3418 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3419 the target's overriding subprogram kind.
3420
3421 @node Pragma Implicit_Packing
3422 @unnumberedsec Pragma Implicit_Packing
3423 @findex Implicit_Packing
3424 @cindex Rational Profile
3425 @noindent
3426 Syntax:
3427
3428 @smallexample @c ada
3429 pragma Implicit_Packing;
3430 @end smallexample
3431
3432 @noindent
3433 This is a configuration pragma that requests implicit packing for packed
3434 arrays for which a size clause is given but no explicit pragma Pack or
3435 specification of Component_Size is present. It also applies to records
3436 where no record representation clause is present. Consider this example:
3437
3438 @smallexample @c ada
3439 type R is array (0 .. 7) of Boolean;
3440 for R'Size use 8;
3441 @end smallexample
3442
3443 @noindent
3444 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3445 does not change the layout of a composite object. So the Size clause in the
3446 above example is normally rejected, since the default layout of the array uses
3447 8-bit components, and thus the array requires a minimum of 64 bits.
3448
3449 If this declaration is compiled in a region of code covered by an occurrence
3450 of the configuration pragma Implicit_Packing, then the Size clause in this
3451 and similar examples will cause implicit packing and thus be accepted. For
3452 this implicit packing to occur, the type in question must be an array of small
3453 components whose size is known at compile time, and the Size clause must
3454 specify the exact size that corresponds to the number of elements in the array
3455 multiplied by the size in bits of the component type (both single and
3456 multi-dimensioned arrays can be controlled with this pragma).
3457
3458 @cindex Array packing
3459
3460 Similarly, the following example shows the use in the record case
3461
3462 @smallexample @c ada
3463 type r is record
3464 a, b, c, d, e, f, g, h : boolean;
3465 chr : character;
3466 end record;
3467 for r'size use 16;
3468 @end smallexample
3469
3470 @noindent
3471 Without a pragma Pack, each Boolean field requires 8 bits, so the
3472 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3473 sufficient. The use of pragma Implicit_Packing allows this record
3474 declaration to compile without an explicit pragma Pack.
3475 @node Pragma Import_Exception
3476 @unnumberedsec Pragma Import_Exception
3477 @cindex OpenVMS
3478 @findex Import_Exception
3479 @noindent
3480 Syntax:
3481
3482 @smallexample @c ada
3483 pragma Import_Exception (
3484 [Internal =>] LOCAL_NAME
3485 [, [External =>] EXTERNAL_SYMBOL]
3486 [, [Form =>] Ada | VMS]
3487 [, [Code =>] static_integer_EXPRESSION]);
3488
3489 EXTERNAL_SYMBOL ::=
3490 IDENTIFIER
3491 | static_string_EXPRESSION
3492 @end smallexample
3493
3494 @noindent
3495 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3496 It allows OpenVMS conditions (for example, from OpenVMS system services or
3497 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3498 The pragma specifies that the exception associated with an exception
3499 declaration in an Ada program be defined externally (in non-Ada code).
3500 For further details on this pragma, see the
3501 DEC Ada Language Reference Manual, section 13.9a.3.1.
3502
3503 @node Pragma Import_Function
3504 @unnumberedsec Pragma Import_Function
3505 @findex Import_Function
3506 @noindent
3507 Syntax:
3508
3509 @smallexample @c ada
3510 pragma Import_Function (
3511 [Internal =>] LOCAL_NAME,
3512 [, [External =>] EXTERNAL_SYMBOL]
3513 [, [Parameter_Types =>] PARAMETER_TYPES]
3514 [, [Result_Type =>] SUBTYPE_MARK]
3515 [, [Mechanism =>] MECHANISM]
3516 [, [Result_Mechanism =>] MECHANISM_NAME]
3517 [, [First_Optional_Parameter =>] IDENTIFIER]);
3518
3519 EXTERNAL_SYMBOL ::=
3520 IDENTIFIER
3521 | static_string_EXPRESSION
3522
3523 PARAMETER_TYPES ::=
3524 null
3525 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3526
3527 TYPE_DESIGNATOR ::=
3528 subtype_NAME
3529 | subtype_Name ' Access
3530
3531 MECHANISM ::=
3532 MECHANISM_NAME
3533 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3534
3535 MECHANISM_ASSOCIATION ::=
3536 [formal_parameter_NAME =>] MECHANISM_NAME
3537
3538 MECHANISM_NAME ::=
3539 Value
3540 | Reference
3541 | Descriptor [([Class =>] CLASS_NAME)]
3542 | Short_Descriptor [([Class =>] CLASS_NAME)]
3543
3544 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3545 @end smallexample
3546
3547 @noindent
3548 This pragma is used in conjunction with a pragma @code{Import} to
3549 specify additional information for an imported function. The pragma
3550 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3551 @code{Import_Function} pragma and both must appear in the same
3552 declarative part as the function specification.
3553
3554 The @var{Internal} argument must uniquely designate
3555 the function to which the
3556 pragma applies. If more than one function name exists of this name in
3557 the declarative part you must use the @code{Parameter_Types} and
3558 @var{Result_Type} parameters to achieve the required unique
3559 designation. Subtype marks in these parameters must exactly match the
3560 subtypes in the corresponding function specification, using positional
3561 notation to match parameters with subtype marks.
3562 The form with an @code{'Access} attribute can be used to match an
3563 anonymous access parameter.
3564
3565 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3566 parameters to specify passing mechanisms for the
3567 parameters and result. If you specify a single mechanism name, it
3568 applies to all parameters. Otherwise you may specify a mechanism on a
3569 parameter by parameter basis using either positional or named
3570 notation. If the mechanism is not specified, the default mechanism
3571 is used.
3572
3573 @cindex OpenVMS
3574 @cindex Passing by descriptor
3575 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3576 The default behavior for Import_Function is to pass a 64bit descriptor
3577 unless short_descriptor is specified, then a 32bit descriptor is passed.
3578
3579 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3580 It specifies that the designated parameter and all following parameters
3581 are optional, meaning that they are not passed at the generated code
3582 level (this is distinct from the notion of optional parameters in Ada
3583 where the parameters are passed anyway with the designated optional
3584 parameters). All optional parameters must be of mode @code{IN} and have
3585 default parameter values that are either known at compile time
3586 expressions, or uses of the @code{'Null_Parameter} attribute.
3587
3588 @node Pragma Import_Object
3589 @unnumberedsec Pragma Import_Object
3590 @findex Import_Object
3591 @noindent
3592 Syntax:
3593
3594 @smallexample @c ada
3595 pragma Import_Object
3596 [Internal =>] LOCAL_NAME
3597 [, [External =>] EXTERNAL_SYMBOL]
3598 [, [Size =>] EXTERNAL_SYMBOL]);
3599
3600 EXTERNAL_SYMBOL ::=
3601 IDENTIFIER
3602 | static_string_EXPRESSION
3603 @end smallexample
3604
3605 @noindent
3606 This pragma designates an object as imported, and apart from the
3607 extended rules for external symbols, is identical in effect to the use of
3608 the normal @code{Import} pragma applied to an object. Unlike the
3609 subprogram case, you need not use a separate @code{Import} pragma,
3610 although you may do so (and probably should do so from a portability
3611 point of view). @var{size} is syntax checked, but otherwise ignored by
3612 GNAT@.
3613
3614 @node Pragma Import_Procedure
3615 @unnumberedsec Pragma Import_Procedure
3616 @findex Import_Procedure
3617 @noindent
3618 Syntax:
3619
3620 @smallexample @c ada
3621 pragma Import_Procedure (
3622 [Internal =>] LOCAL_NAME
3623 [, [External =>] EXTERNAL_SYMBOL]
3624 [, [Parameter_Types =>] PARAMETER_TYPES]
3625 [, [Mechanism =>] MECHANISM]
3626 [, [First_Optional_Parameter =>] IDENTIFIER]);
3627
3628 EXTERNAL_SYMBOL ::=
3629 IDENTIFIER
3630 | static_string_EXPRESSION
3631
3632 PARAMETER_TYPES ::=
3633 null
3634 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3635
3636 TYPE_DESIGNATOR ::=
3637 subtype_NAME
3638 | subtype_Name ' Access
3639
3640 MECHANISM ::=
3641 MECHANISM_NAME
3642 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3643
3644 MECHANISM_ASSOCIATION ::=
3645 [formal_parameter_NAME =>] MECHANISM_NAME
3646
3647 MECHANISM_NAME ::=
3648 Value
3649 | Reference
3650 | Descriptor [([Class =>] CLASS_NAME)]
3651 | Short_Descriptor [([Class =>] CLASS_NAME)]
3652
3653 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3654 @end smallexample
3655
3656 @noindent
3657 This pragma is identical to @code{Import_Function} except that it
3658 applies to a procedure rather than a function and the parameters
3659 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3660
3661 @node Pragma Import_Valued_Procedure
3662 @unnumberedsec Pragma Import_Valued_Procedure
3663 @findex Import_Valued_Procedure
3664 @noindent
3665 Syntax:
3666
3667 @smallexample @c ada
3668 pragma Import_Valued_Procedure (
3669 [Internal =>] LOCAL_NAME
3670 [, [External =>] EXTERNAL_SYMBOL]
3671 [, [Parameter_Types =>] PARAMETER_TYPES]
3672 [, [Mechanism =>] MECHANISM]
3673 [, [First_Optional_Parameter =>] IDENTIFIER]);
3674
3675 EXTERNAL_SYMBOL ::=
3676 IDENTIFIER
3677 | static_string_EXPRESSION
3678
3679 PARAMETER_TYPES ::=
3680 null
3681 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3682
3683 TYPE_DESIGNATOR ::=
3684 subtype_NAME
3685 | subtype_Name ' Access
3686
3687 MECHANISM ::=
3688 MECHANISM_NAME
3689 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3690
3691 MECHANISM_ASSOCIATION ::=
3692 [formal_parameter_NAME =>] MECHANISM_NAME
3693
3694 MECHANISM_NAME ::=
3695 Value
3696 | Reference
3697 | Descriptor [([Class =>] CLASS_NAME)]
3698 | Short_Descriptor [([Class =>] CLASS_NAME)]
3699
3700 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3701 @end smallexample
3702
3703 @noindent
3704 This pragma is identical to @code{Import_Procedure} except that the
3705 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3706 mode @code{OUT}, and externally the subprogram is treated as a function
3707 with this parameter as the result of the function. The purpose of this
3708 capability is to allow the use of @code{OUT} and @code{IN OUT}
3709 parameters in interfacing to external functions (which are not permitted
3710 in Ada functions). You may optionally use the @code{Mechanism}
3711 parameters to specify passing mechanisms for the parameters.
3712 If you specify a single mechanism name, it applies to all parameters.
3713 Otherwise you may specify a mechanism on a parameter by parameter
3714 basis using either positional or named notation. If the mechanism is not
3715 specified, the default mechanism is used.
3716
3717 Note that it is important to use this pragma in conjunction with a separate
3718 pragma Import that specifies the desired convention, since otherwise the
3719 default convention is Ada, which is almost certainly not what is required.
3720
3721 @node Pragma Independent
3722 @unnumberedsec Pragma Independent
3723 @findex Independent
3724 @noindent
3725 Syntax:
3726
3727 @smallexample @c ada
3728 pragma Independent (Local_NAME);
3729 @end smallexample
3730
3731 @noindent
3732 This pragma is standard in Ada 2012 mode (which also provides an aspect
3733 of the same name). It is also available as an implementation-defined
3734 pragma in all earlier versions. It specifies that the
3735 designated object or all objects of the designated type must be
3736 independently addressable. This means that separate tasks can safely
3737 manipulate such objects. For example, if two components of a record are
3738 independent, then two separate tasks may access these two components.
3739 This may place
3740 constraints on the representation of the object (for instance prohibiting
3741 tight packing).
3742
3743 @node Pragma Independent_Components
3744 @unnumberedsec Pragma Independent_Components
3745 @findex Independent_Components
3746 @noindent
3747 Syntax:
3748
3749 @smallexample @c ada
3750 pragma Independent_Components (Local_NAME);
3751 @end smallexample
3752
3753 @noindent
3754 This pragma is standard in Ada 2012 mode (which also provides an aspect
3755 of the same name). It is also available as an implementation-defined
3756 pragma in all earlier versions. It specifies that the components of the
3757 designated object, or the components of each object of the designated
3758 type, must be
3759 independently addressable. This means that separate tasks can safely
3760 manipulate separate components in the composite object. This may place
3761 constraints on the representation of the object (for instance prohibiting
3762 tight packing).
3763
3764 @node Pragma Initial_Condition
3765 @unnumberedsec Pragma Initial_Condition
3766 @findex Initial_Condition
3767 @noindent
3768 For the description of this pragma, see SPARK 2014 Reference Manual,
3769 section 7.1.6.
3770
3771 @node Pragma Initialize_Scalars
3772 @unnumberedsec Pragma Initialize_Scalars
3773 @findex Initialize_Scalars
3774 @cindex debugging with Initialize_Scalars
3775 @noindent
3776 Syntax:
3777
3778 @smallexample @c ada
3779 pragma Initialize_Scalars;
3780 @end smallexample
3781
3782 @noindent
3783 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3784 two important differences. First, there is no requirement for the pragma
3785 to be used uniformly in all units of a partition, in particular, it is fine
3786 to use this just for some or all of the application units of a partition,
3787 without needing to recompile the run-time library.
3788
3789 In the case where some units are compiled with the pragma, and some without,
3790 then a declaration of a variable where the type is defined in package
3791 Standard or is locally declared will always be subject to initialization,
3792 as will any declaration of a scalar variable. For composite variables,
3793 whether the variable is initialized may also depend on whether the package
3794 in which the type of the variable is declared is compiled with the pragma.
3795
3796 The other important difference is that you can control the value used
3797 for initializing scalar objects. At bind time, you can select several
3798 options for initialization. You can
3799 initialize with invalid values (similar to Normalize_Scalars, though for
3800 Initialize_Scalars it is not always possible to determine the invalid
3801 values in complex cases like signed component fields with non-standard
3802 sizes). You can also initialize with high or
3803 low values, or with a specified bit pattern. See the @value{EDITION}
3804 User's Guide for binder options for specifying these cases.
3805
3806 This means that you can compile a program, and then without having to
3807 recompile the program, you can run it with different values being used
3808 for initializing otherwise uninitialized values, to test if your program
3809 behavior depends on the choice. Of course the behavior should not change,
3810 and if it does, then most likely you have an incorrect reference to an
3811 uninitialized value.
3812
3813 It is even possible to change the value at execution time eliminating even
3814 the need to rebind with a different switch using an environment variable.
3815 See the @value{EDITION} User's Guide for details.
3816
3817 Note that pragma @code{Initialize_Scalars} is particularly useful in
3818 conjunction with the enhanced validity checking that is now provided
3819 in GNAT, which checks for invalid values under more conditions.
3820 Using this feature (see description of the @option{-gnatV} flag in the
3821 @value{EDITION} User's Guide) in conjunction with
3822 pragma @code{Initialize_Scalars}
3823 provides a powerful new tool to assist in the detection of problems
3824 caused by uninitialized variables.
3825
3826 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3827 effect on the generated code. This may cause your code to be
3828 substantially larger. It may also cause an increase in the amount
3829 of stack required, so it is probably a good idea to turn on stack
3830 checking (see description of stack checking in the @value{EDITION}
3831 User's Guide) when using this pragma.
3832
3833 @node Pragma Initializes
3834 @unnumberedsec Pragma Initializes
3835 @findex Initializes
3836 @noindent
3837 For the description of this pragma, see SPARK 2014 Reference Manual,
3838 section 7.1.5.
3839
3840 @node Pragma Inline_Always
3841 @unnumberedsec Pragma Inline_Always
3842 @findex Inline_Always
3843 @noindent
3844 Syntax:
3845
3846 @smallexample @c ada
3847 pragma Inline_Always (NAME [, NAME]);
3848 @end smallexample
3849
3850 @noindent
3851 Similar to pragma @code{Inline} except that inlining is not subject to
3852 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3853 happens regardless of whether these options are used.
3854
3855 @node Pragma Inline_Generic
3856 @unnumberedsec Pragma Inline_Generic
3857 @findex Inline_Generic
3858 @noindent
3859 Syntax:
3860
3861 @smallexample @c ada
3862 pragma Inline_Generic (GNAME @{, GNAME@});
3863
3864 GNAME ::= generic_unit_NAME | generic_instance_NAME
3865 @end smallexample
3866
3867 @noindent
3868 This pragma is provided for compatibility with Dec Ada 83. It has
3869 no effect in @code{GNAT} (which always inlines generics), other
3870 than to check that the given names are all names of generic units or
3871 generic instances.
3872
3873 @node Pragma Interface
3874 @unnumberedsec Pragma Interface
3875 @findex Interface
3876 @noindent
3877 Syntax:
3878
3879 @smallexample @c ada
3880 pragma Interface (
3881 [Convention =>] convention_identifier,
3882 [Entity =>] local_NAME
3883 [, [External_Name =>] static_string_expression]
3884 [, [Link_Name =>] static_string_expression]);
3885 @end smallexample
3886
3887 @noindent
3888 This pragma is identical in syntax and semantics to
3889 the standard Ada pragma @code{Import}. It is provided for compatibility
3890 with Ada 83. The definition is upwards compatible both with pragma
3891 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3892 with some extended implementations of this pragma in certain Ada 83
3893 implementations. The only difference between pragma @code{Interface}
3894 and pragma @code{Import} is that there is special circuitry to allow
3895 both pragmas to appear for the same subprogram entity (normally it
3896 is illegal to have multiple @code{Import} pragmas. This is useful in
3897 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3898 Ada 83 compilers.
3899
3900 @node Pragma Interface_Name
3901 @unnumberedsec Pragma Interface_Name
3902 @findex Interface_Name
3903 @noindent
3904 Syntax:
3905
3906 @smallexample @c ada
3907 pragma Interface_Name (
3908 [Entity =>] LOCAL_NAME
3909 [, [External_Name =>] static_string_EXPRESSION]
3910 [, [Link_Name =>] static_string_EXPRESSION]);
3911 @end smallexample
3912
3913 @noindent
3914 This pragma provides an alternative way of specifying the interface name
3915 for an interfaced subprogram, and is provided for compatibility with Ada
3916 83 compilers that use the pragma for this purpose. You must provide at
3917 least one of @var{External_Name} or @var{Link_Name}.
3918
3919 @node Pragma Interrupt_Handler
3920 @unnumberedsec Pragma Interrupt_Handler
3921 @findex Interrupt_Handler
3922 @noindent
3923 Syntax:
3924
3925 @smallexample @c ada
3926 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3927 @end smallexample
3928
3929 @noindent
3930 This program unit pragma is supported for parameterless protected procedures
3931 as described in Annex C of the Ada Reference Manual. On the AAMP target
3932 the pragma can also be specified for nonprotected parameterless procedures
3933 that are declared at the library level (which includes procedures
3934 declared at the top level of a library package). In the case of AAMP,
3935 when this pragma is applied to a nonprotected procedure, the instruction
3936 @code{IERET} is generated for returns from the procedure, enabling
3937 maskable interrupts, in place of the normal return instruction.
3938
3939 @node Pragma Interrupt_State
3940 @unnumberedsec Pragma Interrupt_State
3941 @findex Interrupt_State
3942 @noindent
3943 Syntax:
3944
3945 @smallexample @c ada
3946 pragma Interrupt_State
3947 ([Name =>] value,
3948 [State =>] SYSTEM | RUNTIME | USER);
3949 @end smallexample
3950
3951 @noindent
3952 Normally certain interrupts are reserved to the implementation. Any attempt
3953 to attach an interrupt causes Program_Error to be raised, as described in
3954 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3955 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3956 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3957 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3958 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3959 Ada exceptions, or used to implement run-time functions such as the
3960 @code{abort} statement and stack overflow checking.
3961
3962 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3963 such uses of interrupts. It subsumes the functionality of pragma
3964 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3965 available on Windows or VMS. On all other platforms than VxWorks,
3966 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3967 and may be used to mark interrupts required by the board support package
3968 as reserved.
3969
3970 Interrupts can be in one of three states:
3971 @itemize @bullet
3972 @item System
3973
3974 The interrupt is reserved (no Ada handler can be installed), and the
3975 Ada run-time may not install a handler. As a result you are guaranteed
3976 standard system default action if this interrupt is raised.
3977
3978 @item Runtime
3979
3980 The interrupt is reserved (no Ada handler can be installed). The run time
3981 is allowed to install a handler for internal control purposes, but is
3982 not required to do so.
3983
3984 @item User
3985
3986 The interrupt is unreserved. The user may install a handler to provide
3987 some other action.
3988 @end itemize
3989
3990 @noindent
3991 These states are the allowed values of the @code{State} parameter of the
3992 pragma. The @code{Name} parameter is a value of the type
3993 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3994 @code{Ada.Interrupts.Names}.
3995
3996 This is a configuration pragma, and the binder will check that there
3997 are no inconsistencies between different units in a partition in how a
3998 given interrupt is specified. It may appear anywhere a pragma is legal.
3999
4000 The effect is to move the interrupt to the specified state.
4001
4002 By declaring interrupts to be SYSTEM, you guarantee the standard system
4003 action, such as a core dump.
4004
4005 By declaring interrupts to be USER, you guarantee that you can install
4006 a handler.
4007
4008 Note that certain signals on many operating systems cannot be caught and
4009 handled by applications. In such cases, the pragma is ignored. See the
4010 operating system documentation, or the value of the array @code{Reserved}
4011 declared in the spec of package @code{System.OS_Interface}.
4012
4013 Overriding the default state of signals used by the Ada runtime may interfere
4014 with an application's runtime behavior in the cases of the synchronous signals,
4015 and in the case of the signal used to implement the @code{abort} statement.
4016
4017 @node Pragma Invariant
4018 @unnumberedsec Pragma Invariant
4019 @findex Invariant
4020 @noindent
4021 Syntax:
4022
4023 @smallexample @c ada
4024 pragma Invariant
4025 ([Entity =>] private_type_LOCAL_NAME,
4026 [Check =>] EXPRESSION
4027 [,[Message =>] String_Expression]);
4028 @end smallexample
4029
4030 @noindent
4031 This pragma provides exactly the same capabilities as the Type_Invariant aspect
4032 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
4033 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
4034 requires the use of the aspect syntax, which is not available except in 2012
4035 mode, it is not possible to use the Type_Invariant aspect in earlier versions
4036 of Ada. However the Invariant pragma may be used in any version of Ada. Also
4037 note that the aspect Invariant is a synonym in GNAT for the aspect
4038 Type_Invariant, but there is no pragma Type_Invariant.
4039
4040 The pragma must appear within the visible part of the package specification,
4041 after the type to which its Entity argument appears. As with the Invariant
4042 aspect, the Check expression is not analyzed until the end of the visible
4043 part of the package, so it may contain forward references. The Message
4044 argument, if present, provides the exception message used if the invariant
4045 is violated. If no Message parameter is provided, a default message that
4046 identifies the line on which the pragma appears is used.
4047
4048 It is permissible to have multiple Invariants for the same type entity, in
4049 which case they are and'ed together. It is permissible to use this pragma
4050 in Ada 2012 mode, but you cannot have both an invariant aspect and an
4051 invariant pragma for the same entity.
4052
4053 For further details on the use of this pragma, see the Ada 2012 documentation
4054 of the Type_Invariant aspect.
4055
4056 @node Pragma Java_Constructor
4057 @unnumberedsec Pragma Java_Constructor
4058 @findex Java_Constructor
4059 @noindent
4060 Syntax:
4061
4062 @smallexample @c ada
4063 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
4064 @end smallexample
4065
4066 @noindent
4067 This pragma is used to assert that the specified Ada function should be
4068 mapped to the Java constructor for some Ada tagged record type.
4069
4070 See section 7.3.2 of the
4071 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4072 for related information.
4073
4074 @node Pragma Java_Interface
4075 @unnumberedsec Pragma Java_Interface
4076 @findex Java_Interface
4077 @noindent
4078 Syntax:
4079
4080 @smallexample @c ada
4081 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
4082 @end smallexample
4083
4084 @noindent
4085 This pragma is used to assert that the specified Ada abstract tagged type
4086 is to be mapped to a Java interface name.
4087
4088 See sections 7.1 and 7.2 of the
4089 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4090 for related information.
4091
4092 @node Pragma Keep_Names
4093 @unnumberedsec Pragma Keep_Names
4094 @findex Keep_Names
4095 @noindent
4096 Syntax:
4097
4098 @smallexample @c ada
4099 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4100 @end smallexample
4101
4102 @noindent
4103 The @var{LOCAL_NAME} argument
4104 must refer to an enumeration first subtype
4105 in the current declarative part. The effect is to retain the enumeration
4106 literal names for use by @code{Image} and @code{Value} even if a global
4107 @code{Discard_Names} pragma applies. This is useful when you want to
4108 generally suppress enumeration literal names and for example you therefore
4109 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
4110 want to retain the names for specific enumeration types.
4111
4112 @node Pragma License
4113 @unnumberedsec Pragma License
4114 @findex License
4115 @cindex License checking
4116 @noindent
4117 Syntax:
4118
4119 @smallexample @c ada
4120 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4121 @end smallexample
4122
4123 @noindent
4124 This pragma is provided to allow automated checking for appropriate license
4125 conditions with respect to the standard and modified GPL@. A pragma
4126 @code{License}, which is a configuration pragma that typically appears at
4127 the start of a source file or in a separate @file{gnat.adc} file, specifies
4128 the licensing conditions of a unit as follows:
4129
4130 @itemize @bullet
4131 @item Unrestricted
4132 This is used for a unit that can be freely used with no license restrictions.
4133 Examples of such units are public domain units, and units from the Ada
4134 Reference Manual.
4135
4136 @item GPL
4137 This is used for a unit that is licensed under the unmodified GPL, and which
4138 therefore cannot be @code{with}'ed by a restricted unit.
4139
4140 @item Modified_GPL
4141 This is used for a unit licensed under the GNAT modified GPL that includes
4142 a special exception paragraph that specifically permits the inclusion of
4143 the unit in programs without requiring the entire program to be released
4144 under the GPL@.
4145
4146 @item Restricted
4147 This is used for a unit that is restricted in that it is not permitted to
4148 depend on units that are licensed under the GPL@. Typical examples are
4149 proprietary code that is to be released under more restrictive license
4150 conditions. Note that restricted units are permitted to @code{with} units
4151 which are licensed under the modified GPL (this is the whole point of the
4152 modified GPL).
4153
4154 @end itemize
4155
4156 @noindent
4157 Normally a unit with no @code{License} pragma is considered to have an
4158 unknown license, and no checking is done. However, standard GNAT headers
4159 are recognized, and license information is derived from them as follows.
4160
4161 A GNAT license header starts with a line containing 78 hyphens. The following
4162 comment text is searched for the appearance of any of the following strings.
4163
4164 If the string ``GNU General Public License'' is found, then the unit is assumed
4165 to have GPL license, unless the string ``As a special exception'' follows, in
4166 which case the license is assumed to be modified GPL@.
4167
4168 If one of the strings
4169 ``This specification is adapted from the Ada Semantic Interface'' or
4170 ``This specification is derived from the Ada Reference Manual'' is found
4171 then the unit is assumed to be unrestricted.
4172
4173 @noindent
4174 These default actions means that a program with a restricted license pragma
4175 will automatically get warnings if a GPL unit is inappropriately
4176 @code{with}'ed. For example, the program:
4177
4178 @smallexample @c ada
4179 with Sem_Ch3;
4180 with GNAT.Sockets;
4181 procedure Secret_Stuff is
4182 @dots{}
4183 end Secret_Stuff
4184 @end smallexample
4185
4186 @noindent
4187 if compiled with pragma @code{License} (@code{Restricted}) in a
4188 @file{gnat.adc} file will generate the warning:
4189
4190 @smallexample
4191 1. with Sem_Ch3;
4192 |
4193 >>> license of withed unit "Sem_Ch3" is incompatible
4194
4195 2. with GNAT.Sockets;
4196 3. procedure Secret_Stuff is
4197 @end smallexample
4198
4199 @noindent
4200 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4201 compiler and is licensed under the
4202 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4203 run time, and is therefore licensed under the modified GPL@.
4204
4205 @node Pragma Link_With
4206 @unnumberedsec Pragma Link_With
4207 @findex Link_With
4208 @noindent
4209 Syntax:
4210
4211 @smallexample @c ada
4212 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4213 @end smallexample
4214
4215 @noindent
4216 This pragma is provided for compatibility with certain Ada 83 compilers.
4217 It has exactly the same effect as pragma @code{Linker_Options} except
4218 that spaces occurring within one of the string expressions are treated
4219 as separators. For example, in the following case:
4220
4221 @smallexample @c ada
4222 pragma Link_With ("-labc -ldef");
4223 @end smallexample
4224
4225 @noindent
4226 results in passing the strings @code{-labc} and @code{-ldef} as two
4227 separate arguments to the linker. In addition pragma Link_With allows
4228 multiple arguments, with the same effect as successive pragmas.
4229
4230 @node Pragma Linker_Alias
4231 @unnumberedsec Pragma Linker_Alias
4232 @findex Linker_Alias
4233 @noindent
4234 Syntax:
4235
4236 @smallexample @c ada
4237 pragma Linker_Alias (
4238 [Entity =>] LOCAL_NAME,
4239 [Target =>] static_string_EXPRESSION);
4240 @end smallexample
4241
4242 @noindent
4243 @var{LOCAL_NAME} must refer to an object that is declared at the library
4244 level. This pragma establishes the given entity as a linker alias for the
4245 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4246 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4247 @var{static_string_EXPRESSION} in the object file, that is to say no space
4248 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4249 to the same address as @var{static_string_EXPRESSION} by the linker.
4250
4251 The actual linker name for the target must be used (e.g.@: the fully
4252 encoded name with qualification in Ada, or the mangled name in C++),
4253 or it must be declared using the C convention with @code{pragma Import}
4254 or @code{pragma Export}.
4255
4256 Not all target machines support this pragma. On some of them it is accepted
4257 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4258
4259 @smallexample @c ada
4260 -- Example of the use of pragma Linker_Alias
4261
4262 package p is
4263 i : Integer := 1;
4264 pragma Export (C, i);
4265
4266 new_name_for_i : Integer;
4267 pragma Linker_Alias (new_name_for_i, "i");
4268 end p;
4269 @end smallexample
4270
4271 @node Pragma Linker_Constructor
4272 @unnumberedsec Pragma Linker_Constructor
4273 @findex Linker_Constructor
4274 @noindent
4275 Syntax:
4276
4277 @smallexample @c ada
4278 pragma Linker_Constructor (procedure_LOCAL_NAME);
4279 @end smallexample
4280
4281 @noindent
4282 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4283 is declared at the library level. A procedure to which this pragma is
4284 applied will be treated as an initialization routine by the linker.
4285 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4286 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4287 of the executable is called (or immediately after the shared library is
4288 loaded if the procedure is linked in a shared library), in particular
4289 before the Ada run-time environment is set up.
4290
4291 Because of these specific contexts, the set of operations such a procedure
4292 can perform is very limited and the type of objects it can manipulate is
4293 essentially restricted to the elementary types. In particular, it must only
4294 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4295
4296 This pragma is used by GNAT to implement auto-initialization of shared Stand
4297 Alone Libraries, which provides a related capability without the restrictions
4298 listed above. Where possible, the use of Stand Alone Libraries is preferable
4299 to the use of this pragma.
4300
4301 @node Pragma Linker_Destructor
4302 @unnumberedsec Pragma Linker_Destructor
4303 @findex Linker_Destructor
4304 @noindent
4305 Syntax:
4306
4307 @smallexample @c ada
4308 pragma Linker_Destructor (procedure_LOCAL_NAME);
4309 @end smallexample
4310
4311 @noindent
4312 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4313 is declared at the library level. A procedure to which this pragma is
4314 applied will be treated as a finalization routine by the linker.
4315 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4316 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4317 of the executable has exited (or immediately before the shared library
4318 is unloaded if the procedure is linked in a shared library), in particular
4319 after the Ada run-time environment is shut down.
4320
4321 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4322 because of these specific contexts.
4323
4324 @node Pragma Linker_Section
4325 @unnumberedsec Pragma Linker_Section
4326 @findex Linker_Section
4327 @noindent
4328 Syntax:
4329
4330 @smallexample @c ada
4331 pragma Linker_Section (
4332 [Entity =>] LOCAL_NAME,
4333 [Section =>] static_string_EXPRESSION);
4334 @end smallexample
4335
4336 @noindent
4337 @var{LOCAL_NAME} must refer to an object, type, or subprogram that is
4338 declared at the library level. This pragma specifies the name of the
4339 linker section for the given entity. It is equivalent to
4340 @code{__attribute__((section))} in GNU C and causes @var{LOCAL_NAME} to
4341 be placed in the @var{static_string_EXPRESSION} section of the
4342 executable (assuming the linker doesn't rename the section).
4343 GNAT also provides an implementation defined aspect of the same name.
4344
4345 In the case of specifying this aspect for a type, the effect is to
4346 specify the corresponding for all library level objects of the type which
4347 do not have an explicit linker section set. Note that this only applies to
4348 whole objects, not to components of composite objects.
4349
4350 In the case of a subprogram, the linker section applies to all previously
4351 declared matching overloaded subprograms in the current declarative part
4352 which do not already have a linker section assigned. The linker section
4353 aspect is useful in this case for specifying different linker sections
4354 for different elements of such an overloaded set.
4355
4356 Note that an empty string specifies that no linker section is specified.
4357 This is not quite the same as omitting the pragma or aspect, since it
4358 can be used to specify that one element of an overloaded set of subprograms
4359 has the default linker section, or that one object of a type for which a
4360 linker section is specified should has the default linker section.
4361
4362 The compiler normally places library-level entities in standard sections
4363 depending on the class: procedures and functions generally go in the
4364 @code{.text} section, initialized variables in the @code{.data} section
4365 and uninitialized variables in the @code{.bss} section.
4366
4367 Other, special sections may exist on given target machines to map special
4368 hardware, for example I/O ports or flash memory. This pragma is a means to
4369 defer the final layout of the executable to the linker, thus fully working
4370 at the symbolic level with the compiler.
4371
4372 Some file formats do not support arbitrary sections so not all target
4373 machines support this pragma. The use of this pragma may cause a program
4374 execution to be erroneous if it is used to place an entity into an
4375 inappropriate section (e.g.@: a modified variable into the @code{.text}
4376 section). See also @code{pragma Persistent_BSS}.
4377
4378 @smallexample @c ada
4379 -- Example of the use of pragma Linker_Section
4380
4381 package IO_Card is
4382 Port_A : Integer;
4383 pragma Volatile (Port_A);
4384 pragma Linker_Section (Port_A, ".bss.port_a");
4385
4386 Port_B : Integer;
4387 pragma Volatile (Port_B);
4388 pragma Linker_Section (Port_B, ".bss.port_b");
4389
4390 type Port_Type is new Integer with Linker_Section => ".bss";
4391 PA : Port_Type with Linker_Section => ".bss.PA";
4392 PB : Port_Type; -- ends up in linker section ".bss"
4393
4394 procedure Q with Linker_Section => "Qsection";
4395 end IO_Card;
4396 @end smallexample
4397
4398 @node Pragma Long_Float
4399 @unnumberedsec Pragma Long_Float
4400 @cindex OpenVMS
4401 @findex Long_Float
4402 @noindent
4403 Syntax:
4404
4405 @smallexample @c ada
4406 pragma Long_Float (FLOAT_FORMAT);
4407
4408 FLOAT_FORMAT ::= D_Float | G_Float
4409 @end smallexample
4410
4411 @noindent
4412 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4413 It allows control over the internal representation chosen for the predefined
4414 type @code{Long_Float} and for floating point type representations with
4415 @code{digits} specified in the range 7 through 15.
4416 For further details on this pragma, see the
4417 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
4418 this pragma, the standard runtime libraries must be recompiled.
4419
4420 @node Pragma Loop_Invariant
4421 @unnumberedsec Pragma Loop_Invariant
4422 @findex Loop_Invariant
4423 @noindent
4424 Syntax:
4425
4426 @smallexample @c ada
4427 pragma Loop_Invariant ( boolean_EXPRESSION );
4428 @end smallexample
4429
4430 @noindent
4431 The effect of this pragma is similar to that of pragma @code{Assert},
4432 except that in an @code{Assertion_Policy} pragma, the identifier
4433 @code{Loop_Invariant} is used to control whether it is ignored or checked
4434 (or disabled).
4435
4436 @code{Loop_Invariant} can only appear as one of the items in the sequence
4437 of statements of a loop body, or nested inside block statements that
4438 appear in the sequence of statements of a loop body.
4439 The intention is that it be used to
4440 represent a "loop invariant" assertion, i.e. something that is true each
4441 time through the loop, and which can be used to show that the loop is
4442 achieving its purpose.
4443
4444 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4445 apply to the same loop should be grouped in the same sequence of
4446 statements.
4447
4448 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4449 may be used to refer to the value of an expression on entry to the loop. This
4450 attribute can only be used within the expression of a @code{Loop_Invariant}
4451 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4452
4453 @node Pragma Loop_Optimize
4454 @unnumberedsec Pragma Loop_Optimize
4455 @findex Loop_Optimize
4456 @noindent
4457 Syntax:
4458
4459 @smallexample @c ada
4460 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4461
4462 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
4463 @end smallexample
4464
4465 @noindent
4466 This pragma must appear immediately within a loop statement. It allows the
4467 programmer to specify optimization hints for the enclosing loop. The hints
4468 are not mutually exclusive and can be freely mixed, but not all combinations
4469 will yield a sensible outcome.
4470
4471 There are five supported optimization hints for a loop:
4472
4473 @itemize @bullet
4474 @item Ivdep
4475
4476 The programmer asserts that there are no loop-carried dependencies which would prevent consecutive iterations of the loop from being executed simultaneously.
4477
4478 @item No_Unroll
4479
4480 The loop must not be unrolled. This is a strong hint: the compiler will not
4481 unroll a loop marked with this hint.
4482
4483 @item Unroll
4484
4485 The loop should be unrolled. This is a weak hint: the compiler will try to
4486 apply unrolling to this loop preferably to other optimizations, notably
4487 vectorization, but there is no guarantee that the loop will be unrolled.
4488
4489 @item No_Vector
4490
4491 The loop must not be vectorized. This is a strong hint: the compiler will not
4492 vectorize a loop marked with this hint.
4493
4494 @item Vector
4495
4496 The loop should be vectorized. This is a weak hint: the compiler will try to
4497 apply vectorization to this loop preferably to other optimizations, notably
4498 unrolling, but there is no guarantee that the loop will be vectorized.
4499
4500 @end itemize
4501
4502 These hints do not void the need to pass the appropriate switches to the
4503 compiler in order to enable the relevant optimizations, that is to say
4504 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4505 vectorization.
4506
4507 @node Pragma Loop_Variant
4508 @unnumberedsec Pragma Loop_Variant
4509 @findex Loop_Variant
4510 @noindent
4511 Syntax:
4512
4513 @smallexample @c ada
4514 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4515 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4516 CHANGE_DIRECTION ::= Increases | Decreases
4517 @end smallexample
4518
4519 @noindent
4520 @code{Loop_Variant} can only appear as one of the items in the sequence
4521 of statements of a loop body, or nested inside block statements that
4522 appear in the sequence of statements of a loop body.
4523 It allows the specification of quantities which must always
4524 decrease or increase in successive iterations of the loop. In its simplest
4525 form, just one expression is specified, whose value must increase or decrease
4526 on each iteration of the loop.
4527
4528 In a more complex form, multiple arguments can be given which are intepreted
4529 in a nesting lexicographic manner. For example:
4530
4531 @smallexample @c ada
4532 pragma Loop_Variant (Increases => X, Decreases => Y);
4533 @end smallexample
4534
4535 @noindent
4536 specifies that each time through the loop either X increases, or X stays
4537 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4538 loop is making progress. It can be useful in helping to show informally
4539 or prove formally that the loop always terminates.
4540
4541 @code{Loop_Variant} is an assertion whose effect can be controlled using
4542 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4543 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4544 to ignore the check (in which case the pragma has no effect on the program),
4545 or @code{Disable} in which case the pragma is not even checked for correct
4546 syntax.
4547
4548 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4549 apply to the same loop should be grouped in the same sequence of
4550 statements.
4551
4552 The @code{Loop_Entry} attribute may be used within the expressions of the
4553 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4554
4555 @node Pragma Machine_Attribute
4556 @unnumberedsec Pragma Machine_Attribute
4557 @findex Machine_Attribute
4558 @noindent
4559 Syntax:
4560
4561 @smallexample @c ada
4562 pragma Machine_Attribute (
4563 [Entity =>] LOCAL_NAME,
4564 [Attribute_Name =>] static_string_EXPRESSION
4565 [, [Info =>] static_EXPRESSION] );
4566 @end smallexample
4567
4568 @noindent
4569 Machine-dependent attributes can be specified for types and/or
4570 declarations. This pragma is semantically equivalent to
4571 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4572 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4573 in GNU C, where @code{@var{attribute_name}} is recognized by the
4574 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4575 specific macro. A string literal for the optional parameter @var{info}
4576 is transformed into an identifier, which may make this pragma unusable
4577 for some attributes. @xref{Target Attributes,, Defining target-specific
4578 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4579 Internals}, further information.
4580
4581 @node Pragma Main
4582 @unnumberedsec Pragma Main
4583 @cindex OpenVMS
4584 @findex Main
4585 @noindent
4586 Syntax:
4587
4588 @smallexample @c ada
4589 pragma Main
4590 (MAIN_OPTION [, MAIN_OPTION]);
4591
4592 MAIN_OPTION ::=
4593 [Stack_Size =>] static_integer_EXPRESSION
4594 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4595 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
4596 @end smallexample
4597
4598 @noindent
4599 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4600 no effect in GNAT, other than being syntax checked.
4601
4602 @node Pragma Main_Storage
4603 @unnumberedsec Pragma Main_Storage
4604 @cindex OpenVMS
4605 @findex Main_Storage
4606 @noindent
4607 Syntax:
4608
4609 @smallexample @c ada
4610 pragma Main_Storage
4611 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4612
4613 MAIN_STORAGE_OPTION ::=
4614 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4615 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
4616 @end smallexample
4617
4618 @noindent
4619 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4620 no effect in GNAT, other than being syntax checked. Note that the pragma
4621 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4622
4623 @node Pragma No_Body
4624 @unnumberedsec Pragma No_Body
4625 @findex No_Body
4626 @noindent
4627 Syntax:
4628
4629 @smallexample @c ada
4630 pragma No_Body;
4631 @end smallexample
4632
4633 @noindent
4634 There are a number of cases in which a package spec does not require a body,
4635 and in fact a body is not permitted. GNAT will not permit the spec to be
4636 compiled if there is a body around. The pragma No_Body allows you to provide
4637 a body file, even in a case where no body is allowed. The body file must
4638 contain only comments and a single No_Body pragma. This is recognized by
4639 the compiler as indicating that no body is logically present.
4640
4641 This is particularly useful during maintenance when a package is modified in
4642 such a way that a body needed before is no longer needed. The provision of a
4643 dummy body with a No_Body pragma ensures that there is no interference from
4644 earlier versions of the package body.
4645
4646 @node Pragma No_Inline
4647 @unnumberedsec Pragma No_Inline
4648 @findex No_Inline
4649 @noindent
4650 Syntax:
4651
4652 @smallexample @c ada
4653 pragma No_Inline (NAME @{, NAME@});
4654 @end smallexample
4655
4656 @noindent
4657 This pragma suppresses inlining for the callable entity or the instances of
4658 the generic subprogram designated by @var{NAME}, including inlining that
4659 results from the use of pragma @code{Inline}. This pragma is always active,
4660 in particular it is not subject to the use of option @option{-gnatn} or
4661 @option{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
4662 pragma @code{Inline_Always} for the same @var{NAME}.
4663
4664 @node Pragma No_Return
4665 @unnumberedsec Pragma No_Return
4666 @findex No_Return
4667 @noindent
4668 Syntax:
4669
4670 @smallexample @c ada
4671 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4672 @end smallexample
4673
4674 @noindent
4675 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4676 declarations in the current declarative part. A procedure to which this
4677 pragma is applied may not contain any explicit @code{return} statements.
4678 In addition, if the procedure contains any implicit returns from falling
4679 off the end of a statement sequence, then execution of that implicit
4680 return will cause Program_Error to be raised.
4681
4682 One use of this pragma is to identify procedures whose only purpose is to raise
4683 an exception. Another use of this pragma is to suppress incorrect warnings
4684 about missing returns in functions, where the last statement of a function
4685 statement sequence is a call to such a procedure.
4686
4687 Note that in Ada 2005 mode, this pragma is part of the language. It is
4688 available in all earlier versions of Ada as an implementation-defined
4689 pragma.
4690
4691 @node Pragma No_Run_Time
4692 @unnumberedsec Pragma No_Run_Time
4693 @findex No_Run_Time
4694 @noindent
4695 Syntax:
4696
4697 @smallexample @c ada
4698 pragma No_Run_Time;
4699 @end smallexample
4700
4701 @noindent
4702 This is an obsolete configuration pragma that historically was used to
4703 setup what is now called the "zero footprint" library. It causes any
4704 library units outside this basic library to be ignored. The use of
4705 this pragma has been superseded by the general configurable run-time
4706 capability of @code{GNAT} where the compiler takes into account whatever
4707 units happen to be accessible in the library.
4708
4709 @node Pragma No_Strict_Aliasing
4710 @unnumberedsec Pragma No_Strict_Aliasing
4711 @findex No_Strict_Aliasing
4712 @noindent
4713 Syntax:
4714
4715 @smallexample @c ada
4716 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4717 @end smallexample
4718
4719 @noindent
4720 @var{type_LOCAL_NAME} must refer to an access type
4721 declaration in the current declarative part. The effect is to inhibit
4722 strict aliasing optimization for the given type. The form with no
4723 arguments is a configuration pragma which applies to all access types
4724 declared in units to which the pragma applies. For a detailed
4725 description of the strict aliasing optimization, and the situations
4726 in which it must be suppressed, see @ref{Optimization and Strict
4727 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4728
4729 This pragma currently has no effects on access to unconstrained array types.
4730
4731 @node Pragma Normalize_Scalars
4732 @unnumberedsec Pragma Normalize_Scalars
4733 @findex Normalize_Scalars
4734 @noindent
4735 Syntax:
4736
4737 @smallexample @c ada
4738 pragma Normalize_Scalars;
4739 @end smallexample
4740
4741 @noindent
4742 This is a language defined pragma which is fully implemented in GNAT@. The
4743 effect is to cause all scalar objects that are not otherwise initialized
4744 to be initialized. The initial values are implementation dependent and
4745 are as follows:
4746
4747 @table @code
4748 @item Standard.Character
4749 @noindent
4750 Objects whose root type is Standard.Character are initialized to
4751 Character'Last unless the subtype range excludes NUL (in which case
4752 NUL is used). This choice will always generate an invalid value if
4753 one exists.
4754
4755 @item Standard.Wide_Character
4756 @noindent
4757 Objects whose root type is Standard.Wide_Character are initialized to
4758 Wide_Character'Last unless the subtype range excludes NUL (in which case
4759 NUL is used). This choice will always generate an invalid value if
4760 one exists.
4761
4762 @item Standard.Wide_Wide_Character
4763 @noindent
4764 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4765 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4766 which case NUL is used). This choice will always generate an invalid value if
4767 one exists.
4768
4769 @item Integer types
4770 @noindent
4771 Objects of an integer type are treated differently depending on whether
4772 negative values are present in the subtype. If no negative values are
4773 present, then all one bits is used as the initial value except in the
4774 special case where zero is excluded from the subtype, in which case
4775 all zero bits are used. This choice will always generate an invalid
4776 value if one exists.
4777
4778 For subtypes with negative values present, the largest negative number
4779 is used, except in the unusual case where this largest negative number
4780 is in the subtype, and the largest positive number is not, in which case
4781 the largest positive value is used. This choice will always generate
4782 an invalid value if one exists.
4783
4784 @item Floating-Point Types
4785 Objects of all floating-point types are initialized to all 1-bits. For
4786 standard IEEE format, this corresponds to a NaN (not a number) which is
4787 indeed an invalid value.
4788
4789 @item Fixed-Point Types
4790 Objects of all fixed-point types are treated as described above for integers,
4791 with the rules applying to the underlying integer value used to represent
4792 the fixed-point value.
4793
4794 @item Modular types
4795 Objects of a modular type are initialized to all one bits, except in
4796 the special case where zero is excluded from the subtype, in which
4797 case all zero bits are used. This choice will always generate an
4798 invalid value if one exists.
4799
4800 @item Enumeration types
4801 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4802 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4803 whose Pos value is zero, in which case a code of zero is used. This choice
4804 will always generate an invalid value if one exists.
4805
4806 @end table
4807
4808 @node Pragma Obsolescent
4809 @unnumberedsec Pragma Obsolescent
4810 @findex Obsolescent
4811 @noindent
4812 Syntax:
4813
4814 @smallexample @c ada
4815 pragma Obsolescent;
4816
4817 pragma Obsolescent (
4818 [Message =>] static_string_EXPRESSION
4819 [,[Version =>] Ada_05]]);
4820
4821 pragma Obsolescent (
4822 [Entity =>] NAME
4823 [,[Message =>] static_string_EXPRESSION
4824 [,[Version =>] Ada_05]] );
4825 @end smallexample
4826
4827 @noindent
4828 This pragma can occur immediately following a declaration of an entity,
4829 including the case of a record component. If no Entity argument is present,
4830 then this declaration is the one to which the pragma applies. If an Entity
4831 parameter is present, it must either match the name of the entity in this
4832 declaration, or alternatively, the pragma can immediately follow an enumeration
4833 type declaration, where the Entity argument names one of the enumeration
4834 literals.
4835
4836 This pragma is used to indicate that the named entity
4837 is considered obsolescent and should not be used. Typically this is
4838 used when an API must be modified by eventually removing or modifying
4839 existing subprograms or other entities. The pragma can be used at an
4840 intermediate stage when the entity is still present, but will be
4841 removed later.
4842
4843 The effect of this pragma is to output a warning message on a reference to
4844 an entity thus marked that the subprogram is obsolescent if the appropriate
4845 warning option in the compiler is activated. If the Message parameter is
4846 present, then a second warning message is given containing this text. In
4847 addition, a reference to the entity is considered to be a violation of pragma
4848 Restrictions (No_Obsolescent_Features).
4849
4850 This pragma can also be used as a program unit pragma for a package,
4851 in which case the entity name is the name of the package, and the
4852 pragma indicates that the entire package is considered
4853 obsolescent. In this case a client @code{with}'ing such a package
4854 violates the restriction, and the @code{with} statement is
4855 flagged with warnings if the warning option is set.
4856
4857 If the Version parameter is present (which must be exactly
4858 the identifier Ada_05, no other argument is allowed), then the
4859 indication of obsolescence applies only when compiling in Ada 2005
4860 mode. This is primarily intended for dealing with the situations
4861 in the predefined library where subprograms or packages
4862 have become defined as obsolescent in Ada 2005
4863 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4864
4865 The following examples show typical uses of this pragma:
4866
4867 @smallexample @c ada
4868 package p is
4869 pragma Obsolescent (p, Message => "use pp instead of p");
4870 end p;
4871
4872 package q is
4873 procedure q2;
4874 pragma Obsolescent ("use q2new instead");
4875
4876 type R is new integer;
4877 pragma Obsolescent
4878 (Entity => R,
4879 Message => "use RR in Ada 2005",
4880 Version => Ada_05);
4881
4882 type M is record
4883 F1 : Integer;
4884 F2 : Integer;
4885 pragma Obsolescent;
4886 F3 : Integer;
4887 end record;
4888
4889 type E is (a, bc, 'd', quack);
4890 pragma Obsolescent (Entity => bc)
4891 pragma Obsolescent (Entity => 'd')
4892
4893 function "+"
4894 (a, b : character) return character;
4895 pragma Obsolescent (Entity => "+");
4896 end;
4897 @end smallexample
4898
4899 @noindent
4900 Note that, as for all pragmas, if you use a pragma argument identifier,
4901 then all subsequent parameters must also use a pragma argument identifier.
4902 So if you specify "Entity =>" for the Entity argument, and a Message
4903 argument is present, it must be preceded by "Message =>".
4904
4905 @node Pragma Optimize_Alignment
4906 @unnumberedsec Pragma Optimize_Alignment
4907 @findex Optimize_Alignment
4908 @cindex Alignment, default settings
4909 @noindent
4910 Syntax:
4911
4912 @smallexample @c ada
4913 pragma Optimize_Alignment (TIME | SPACE | OFF);
4914 @end smallexample
4915
4916 @noindent
4917 This is a configuration pragma which affects the choice of default alignments
4918 for types and objects where no alignment is explicitly specified. There is a
4919 time/space trade-off in the selection of these values. Large alignments result
4920 in more efficient code, at the expense of larger data space, since sizes have
4921 to be increased to match these alignments. Smaller alignments save space, but
4922 the access code is slower. The normal choice of default alignments for types
4923 and individual alignment promotions for objects (which is what you get if you
4924 do not use this pragma, or if you use an argument of OFF), tries to balance
4925 these two requirements.
4926
4927 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4928 First any packed record is given an alignment of 1. Second, if a size is given
4929 for the type, then the alignment is chosen to avoid increasing this size. For
4930 example, consider:
4931
4932 @smallexample @c ada
4933 type R is record
4934 X : Integer;
4935 Y : Character;
4936 end record;
4937
4938 for R'Size use 5*8;
4939 @end smallexample
4940
4941 @noindent
4942 In the default mode, this type gets an alignment of 4, so that access to the
4943 Integer field X are efficient. But this means that objects of the type end up
4944 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4945 allowed to be bigger than the size of the type, but it can waste space if for
4946 example fields of type R appear in an enclosing record. If the above type is
4947 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4948
4949 However, there is one case in which SPACE is ignored. If a variable length
4950 record (that is a discriminated record with a component which is an array
4951 whose length depends on a discriminant), has a pragma Pack, then it is not
4952 in general possible to set the alignment of such a record to one, so the
4953 pragma is ignored in this case (with a warning).
4954
4955 Specifying SPACE also disables alignment promotions for standalone objects,
4956 which occur when the compiler increases the alignment of a specific object
4957 without changing the alignment of its type.
4958
4959 Specifying TIME causes larger default alignments to be chosen in the case of
4960 small types with sizes that are not a power of 2. For example, consider:
4961
4962 @smallexample @c ada
4963 type R is record
4964 A : Character;
4965 B : Character;
4966 C : Boolean;
4967 end record;
4968
4969 pragma Pack (R);
4970 for R'Size use 17;
4971 @end smallexample
4972
4973 @noindent
4974 The default alignment for this record is normally 1, but if this type is
4975 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4976 to 4, which wastes space for objects of the type, since they are now 4 bytes
4977 long, but results in more efficient access when the whole record is referenced.
4978
4979 As noted above, this is a configuration pragma, and there is a requirement
4980 that all units in a partition be compiled with a consistent setting of the
4981 optimization setting. This would normally be achieved by use of a configuration
4982 pragma file containing the appropriate setting. The exception to this rule is
4983 that units with an explicit configuration pragma in the same file as the source
4984 unit are excluded from the consistency check, as are all predefined units. The
4985 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4986 pragma appears at the start of the file.
4987
4988 @node Pragma Ordered
4989 @unnumberedsec Pragma Ordered
4990 @findex Ordered
4991 @findex pragma @code{Ordered}
4992 @noindent
4993 Syntax:
4994
4995 @smallexample @c ada
4996 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4997 @end smallexample
4998
4999 @noindent
5000 Most enumeration types are from a conceptual point of view unordered.
5001 For example, consider:
5002
5003 @smallexample @c ada
5004 type Color is (Red, Blue, Green, Yellow);
5005 @end smallexample
5006
5007 @noindent
5008 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
5009 but really these relations make no sense; the enumeration type merely
5010 specifies a set of possible colors, and the order is unimportant.
5011
5012 For unordered enumeration types, it is generally a good idea if
5013 clients avoid comparisons (other than equality or inequality) and
5014 explicit ranges. (A @emph{client} is a unit where the type is referenced,
5015 other than the unit where the type is declared, its body, and its subunits.)
5016 For example, if code buried in some client says:
5017
5018 @smallexample @c ada
5019 if Current_Color < Yellow then ...
5020 if Current_Color in Blue .. Green then ...
5021 @end smallexample
5022
5023 @noindent
5024 then the client code is relying on the order, which is undesirable.
5025 It makes the code hard to read and creates maintenance difficulties if
5026 entries have to be added to the enumeration type. Instead,
5027 the code in the client should list the possibilities, or an
5028 appropriate subtype should be declared in the unit that declares
5029 the original enumeration type. E.g., the following subtype could
5030 be declared along with the type @code{Color}:
5031
5032 @smallexample @c ada
5033 subtype RBG is Color range Red .. Green;
5034 @end smallexample
5035
5036 @noindent
5037 and then the client could write:
5038
5039 @smallexample @c ada
5040 if Current_Color in RBG then ...
5041 if Current_Color = Blue or Current_Color = Green then ...
5042 @end smallexample
5043
5044 @noindent
5045 However, some enumeration types are legitimately ordered from a conceptual
5046 point of view. For example, if you declare:
5047
5048 @smallexample @c ada
5049 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
5050 @end smallexample
5051
5052 @noindent
5053 then the ordering imposed by the language is reasonable, and
5054 clients can depend on it, writing for example:
5055
5056 @smallexample @c ada
5057 if D in Mon .. Fri then ...
5058 if D < Wed then ...
5059 @end smallexample
5060
5061 @noindent
5062 The pragma @option{Ordered} is provided to mark enumeration types that
5063 are conceptually ordered, alerting the reader that clients may depend
5064 on the ordering. GNAT provides a pragma to mark enumerations as ordered
5065 rather than one to mark them as unordered, since in our experience,
5066 the great majority of enumeration types are conceptually unordered.
5067
5068 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
5069 and @code{Wide_Wide_Character}
5070 are considered to be ordered types, so each is declared with a
5071 pragma @code{Ordered} in package @code{Standard}.
5072
5073 Normally pragma @code{Ordered} serves only as documentation and a guide for
5074 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
5075 requests warnings for inappropriate uses (comparisons and explicit
5076 subranges) for unordered types. If this switch is used, then any
5077 enumeration type not marked with pragma @code{Ordered} will be considered
5078 as unordered, and will generate warnings for inappropriate uses.
5079
5080 For additional information please refer to the description of the
5081 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
5082
5083 @node Pragma Overflow_Mode
5084 @unnumberedsec Pragma Overflow_Mode
5085 @findex Overflow checks
5086 @findex Overflow mode
5087 @findex pragma @code{Overflow_Mode}
5088 @noindent
5089 Syntax:
5090
5091 @smallexample @c ada
5092 pragma Overflow_Mode
5093 ( [General =>] MODE
5094 [,[Assertions =>] MODE]);
5095
5096 MODE ::= STRICT | MINIMIZED | ELIMINATED
5097 @end smallexample
5098
5099 @noindent
5100 This pragma sets the current overflow mode to the given setting. For details
5101 of the meaning of these modes, please refer to the
5102 ``Overflow Check Handling in GNAT'' appendix in the
5103 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
5104 the given mode applies to all expressions. If both parameters are present,
5105 the @code{General} mode applies to expressions outside assertions, and
5106 the @code{Eliminated} mode applies to expressions within assertions.
5107
5108 The case of the @code{MODE} parameter is ignored,
5109 so @code{MINIMIZED}, @code{Minimized} and
5110 @code{minimized} all have the same effect.
5111
5112 The @code{Overflow_Mode} pragma has the same scoping and placement
5113 rules as pragma @code{Suppress}, so it can occur either as a
5114 configuration pragma, specifying a default for the whole
5115 program, or in a declarative scope, where it applies to the
5116 remaining declarations and statements in that scope.
5117
5118 The pragma @code{Suppress (Overflow_Check)} suppresses
5119 overflow checking, but does not affect the overflow mode.
5120
5121 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
5122 overflow checking, but does not affect the overflow mode.
5123
5124 @node Pragma Overriding_Renamings
5125 @unnumberedsec Pragma Overriding_Renamings
5126 @findex Overriding_Renamings
5127 @cindex Rational profile
5128 @cindex Rational compatibility
5129 @noindent
5130 Syntax:
5131
5132 @smallexample @c ada
5133 pragma Overriding_Renamings;
5134 @end smallexample
5135
5136 @noindent
5137 This is a GNAT configuration pragma to simplify porting
5138 legacy code accepted by the Rational
5139 Ada compiler. In the presence of this pragma, a renaming declaration that
5140 renames an inherited operation declared in the same scope is legal if selected
5141 notation is used as in:
5142
5143 @smallexample @c ada
5144 pragma Overriding_Renamings;
5145 ...
5146 package R is
5147 function F (..);
5148 ...
5149 function F (..) renames R.F;
5150 end R;
5151 @end smallexample
5152
5153 even though
5154 RM 8.3 (15) stipulates that an overridden operation is not visible within the
5155 declaration of the overriding operation.
5156
5157 @node Pragma Partition_Elaboration_Policy
5158 @unnumberedsec Pragma Partition_Elaboration_Policy
5159 @findex Partition_Elaboration_Policy
5160 @noindent
5161 Syntax:
5162
5163 @smallexample @c ada
5164 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
5165
5166 POLICY_IDENTIFIER ::= Concurrent | Sequential
5167 @end smallexample
5168
5169 @noindent
5170 This pragma is standard in Ada 2005, but is available in all earlier
5171 versions of Ada as an implementation-defined pragma.
5172 See Ada 2012 Reference Manual for details.
5173
5174 @node Pragma Part_Of
5175 @unnumberedsec Pragma Part_Of
5176 @findex Part_Of
5177 @noindent
5178 For the description of this pragma, see SPARK 2014 Reference Manual,
5179 section 7.2.6.
5180
5181 @node Pragma Passive
5182 @unnumberedsec Pragma Passive
5183 @findex Passive
5184 @noindent
5185 Syntax:
5186
5187 @smallexample @c ada
5188 pragma Passive [(Semaphore | No)];
5189 @end smallexample
5190
5191 @noindent
5192 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
5193 compatibility with DEC Ada 83 implementations, where it is used within a
5194 task definition to request that a task be made passive. If the argument
5195 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
5196 treats the pragma as an assertion that the containing task is passive
5197 and that optimization of context switch with this task is permitted and
5198 desired. If the argument @code{No} is present, the task must not be
5199 optimized. GNAT does not attempt to optimize any tasks in this manner
5200 (since protected objects are available in place of passive tasks).
5201
5202 For more information on the subject of passive tasks, see the section
5203 ``Passive Task Optimization'' in the GNAT Users Guide.
5204
5205 @node Pragma Persistent_BSS
5206 @unnumberedsec Pragma Persistent_BSS
5207 @findex Persistent_BSS
5208 @noindent
5209 Syntax:
5210
5211 @smallexample @c ada
5212 pragma Persistent_BSS [(LOCAL_NAME)]
5213 @end smallexample
5214
5215 @noindent
5216 This pragma allows selected objects to be placed in the @code{.persistent_bss}
5217 section. On some targets the linker and loader provide for special
5218 treatment of this section, allowing a program to be reloaded without
5219 affecting the contents of this data (hence the name persistent).
5220
5221 There are two forms of usage. If an argument is given, it must be the
5222 local name of a library level object, with no explicit initialization
5223 and whose type is potentially persistent. If no argument is given, then
5224 the pragma is a configuration pragma, and applies to all library level
5225 objects with no explicit initialization of potentially persistent types.
5226
5227 A potentially persistent type is a scalar type, or a non-tagged,
5228 non-discriminated record, all of whose components have no explicit
5229 initialization and are themselves of a potentially persistent type,
5230 or an array, all of whose constraints are static, and whose component
5231 type is potentially persistent.
5232
5233 If this pragma is used on a target where this feature is not supported,
5234 then the pragma will be ignored. See also @code{pragma Linker_Section}.
5235
5236 @node Pragma Polling
5237 @unnumberedsec Pragma Polling
5238 @findex Polling
5239 @noindent
5240 Syntax:
5241
5242 @smallexample @c ada
5243 pragma Polling (ON | OFF);
5244 @end smallexample
5245
5246 @noindent
5247 This pragma controls the generation of polling code. This is normally off.
5248 If @code{pragma Polling (ON)} is used then periodic calls are generated to
5249 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
5250 runtime library, and can be found in file @file{a-excpol.adb}.
5251
5252 Pragma @code{Polling} can appear as a configuration pragma (for example it
5253 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
5254 can be used in the statement or declaration sequence to control polling
5255 more locally.
5256
5257 A call to the polling routine is generated at the start of every loop and
5258 at the start of every subprogram call. This guarantees that the @code{Poll}
5259 routine is called frequently, and places an upper bound (determined by
5260 the complexity of the code) on the period between two @code{Poll} calls.
5261
5262 The primary purpose of the polling interface is to enable asynchronous
5263 aborts on targets that cannot otherwise support it (for example Windows
5264 NT), but it may be used for any other purpose requiring periodic polling.
5265 The standard version is null, and can be replaced by a user program. This
5266 will require re-compilation of the @code{Ada.Exceptions} package that can
5267 be found in files @file{a-except.ads} and @file{a-except.adb}.
5268
5269 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5270 distribution) is used to enable the asynchronous abort capability on
5271 targets that do not normally support the capability. The version of
5272 @code{Poll} in this file makes a call to the appropriate runtime routine
5273 to test for an abort condition.
5274
5275 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5276 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5277 details.
5278
5279 @node Pragma Post
5280 @unnumberedsec Pragma Post
5281 @cindex Post
5282 @cindex Checks, postconditions
5283 @findex Postconditions
5284 @noindent
5285 Syntax:
5286
5287 @smallexample @c ada
5288 pragma Post (Boolean_Expression);
5289 @end smallexample
5290
5291 @noindent
5292 The @code{Post} pragma is intended to be an exact replacement for
5293 the language-defined
5294 @code{Post} aspect, and shares its restrictions and semantics.
5295 It must appear either immediately following the corresponding
5296 subprogram declaration (only other pragmas may intervene), or
5297 if there is no separate subprogram declaration, then it can
5298 appear at the start of the declarations in a subprogram body
5299 (preceded only by other pragmas).
5300
5301 @node Pragma Postcondition
5302 @unnumberedsec Pragma Postcondition
5303 @cindex Postcondition
5304 @cindex Checks, postconditions
5305 @findex Postconditions
5306 @noindent
5307 Syntax:
5308
5309 @smallexample @c ada
5310 pragma Postcondition (
5311 [Check =>] Boolean_Expression
5312 [,[Message =>] String_Expression]);
5313 @end smallexample
5314
5315 @noindent
5316 The @code{Postcondition} pragma allows specification of automatic
5317 postcondition checks for subprograms. These checks are similar to
5318 assertions, but are automatically inserted just prior to the return
5319 statements of the subprogram with which they are associated (including
5320 implicit returns at the end of procedure bodies and associated
5321 exception handlers).
5322
5323 In addition, the boolean expression which is the condition which
5324 must be true may contain references to function'Result in the case
5325 of a function to refer to the returned value.
5326
5327 @code{Postcondition} pragmas may appear either immediately following the
5328 (separate) declaration of a subprogram, or at the start of the
5329 declarations of a subprogram body. Only other pragmas may intervene
5330 (that is appear between the subprogram declaration and its
5331 postconditions, or appear before the postcondition in the
5332 declaration sequence in a subprogram body). In the case of a
5333 postcondition appearing after a subprogram declaration, the
5334 formal arguments of the subprogram are visible, and can be
5335 referenced in the postcondition expressions.
5336
5337 The postconditions are collected and automatically tested just
5338 before any return (implicit or explicit) in the subprogram body.
5339 A postcondition is only recognized if postconditions are active
5340 at the time the pragma is encountered. The compiler switch @option{gnata}
5341 turns on all postconditions by default, and pragma @code{Check_Policy}
5342 with an identifier of @code{Postcondition} can also be used to
5343 control whether postconditions are active.
5344
5345 The general approach is that postconditions are placed in the spec
5346 if they represent functional aspects which make sense to the client.
5347 For example we might have:
5348
5349 @smallexample @c ada
5350 function Direction return Integer;
5351 pragma Postcondition
5352 (Direction'Result = +1
5353 or else
5354 Direction'Result = -1);
5355 @end smallexample
5356
5357 @noindent
5358 which serves to document that the result must be +1 or -1, and
5359 will test that this is the case at run time if postcondition
5360 checking is active.
5361
5362 Postconditions within the subprogram body can be used to
5363 check that some internal aspect of the implementation,
5364 not visible to the client, is operating as expected.
5365 For instance if a square root routine keeps an internal
5366 counter of the number of times it is called, then we
5367 might have the following postcondition:
5368
5369 @smallexample @c ada
5370 Sqrt_Calls : Natural := 0;
5371
5372 function Sqrt (Arg : Float) return Float is
5373 pragma Postcondition
5374 (Sqrt_Calls = Sqrt_Calls'Old + 1);
5375 ...
5376 end Sqrt
5377 @end smallexample
5378
5379 @noindent
5380 As this example, shows, the use of the @code{Old} attribute
5381 is often useful in postconditions to refer to the state on
5382 entry to the subprogram.
5383
5384 Note that postconditions are only checked on normal returns
5385 from the subprogram. If an abnormal return results from
5386 raising an exception, then the postconditions are not checked.
5387
5388 If a postcondition fails, then the exception
5389 @code{System.Assertions.Assert_Failure} is raised. If
5390 a message argument was supplied, then the given string
5391 will be used as the exception message. If no message
5392 argument was supplied, then the default message has
5393 the form "Postcondition failed at file:line". The
5394 exception is raised in the context of the subprogram
5395 body, so it is possible to catch postcondition failures
5396 within the subprogram body itself.
5397
5398 Within a package spec, normal visibility rules
5399 in Ada would prevent forward references within a
5400 postcondition pragma to functions defined later in
5401 the same package. This would introduce undesirable
5402 ordering constraints. To avoid this problem, all
5403 postcondition pragmas are analyzed at the end of
5404 the package spec, allowing forward references.
5405
5406 The following example shows that this even allows
5407 mutually recursive postconditions as in:
5408
5409 @smallexample @c ada
5410 package Parity_Functions is
5411 function Odd (X : Natural) return Boolean;
5412 pragma Postcondition
5413 (Odd'Result =
5414 (x = 1
5415 or else
5416 (x /= 0 and then Even (X - 1))));
5417
5418 function Even (X : Natural) return Boolean;
5419 pragma Postcondition
5420 (Even'Result =
5421 (x = 0
5422 or else
5423 (x /= 1 and then Odd (X - 1))));
5424
5425 end Parity_Functions;
5426 @end smallexample
5427
5428 @noindent
5429 There are no restrictions on the complexity or form of
5430 conditions used within @code{Postcondition} pragmas.
5431 The following example shows that it is even possible
5432 to verify performance behavior.
5433
5434 @smallexample @c ada
5435 package Sort is
5436
5437 Performance : constant Float;
5438 -- Performance constant set by implementation
5439 -- to match target architecture behavior.
5440
5441 procedure Treesort (Arg : String);
5442 -- Sorts characters of argument using N*logN sort
5443 pragma Postcondition
5444 (Float (Clock - Clock'Old) <=
5445 Float (Arg'Length) *
5446 log (Float (Arg'Length)) *
5447 Performance);
5448 end Sort;
5449 @end smallexample
5450
5451 @noindent
5452 Note: postcondition pragmas associated with subprograms that are
5453 marked as Inline_Always, or those marked as Inline with front-end
5454 inlining (-gnatN option set) are accepted and legality-checked
5455 by the compiler, but are ignored at run-time even if postcondition
5456 checking is enabled.
5457
5458 Note that pragma @code{Postcondition} differs from the language-defined
5459 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
5460 multiple occurrences, allowing occurences in the body even if there
5461 is a separate spec, and allowing a second string parameter, and the
5462 use of the pragma identifier @code{Check}. Historically, pragma
5463 @code{Postcondition} was implemented prior to the development of
5464 Ada 2012, and has been retained in its original form for
5465 compatibility purposes.
5466
5467 @node Pragma Post_Class
5468 @unnumberedsec Pragma Post_Class
5469 @cindex Post
5470 @cindex Checks, postconditions
5471 @findex Postconditions
5472 @noindent
5473 Syntax:
5474
5475 @smallexample @c ada
5476 pragma Post_Class (Boolean_Expression);
5477 @end smallexample
5478
5479 @noindent
5480 The @code{Post_Class} pragma is intended to be an exact replacement for
5481 the language-defined
5482 @code{Post'Class} aspect, and shares its restrictions and semantics.
5483 It must appear either immediately following the corresponding
5484 subprogram declaration (only other pragmas may intervene), or
5485 if there is no separate subprogram declaration, then it can
5486 appear at the start of the declarations in a subprogram body
5487 (preceded only by other pragmas).
5488
5489 Note: This pragma is called @code{Post_Class} rather than
5490 @code{Post'Class} because the latter would not be strictly
5491 conforming to the allowed syntax for pragmas. The motivation
5492 for provinding pragmas equivalent to the aspects is to allow a program
5493 to be written using the pragmas, and then compiled if necessary
5494 using an Ada compiler that does not recognize the pragmas or
5495 aspects, but is prepared to ignore the pragmas. The assertion
5496 policy that controls this pragma is @code{Post'Class}, not
5497 @code{Post_Class}.
5498
5499 @node Pragma Pre
5500 @unnumberedsec Pragma Pre
5501 @cindex Pre
5502 @cindex Checks, preconditions
5503 @findex Preconditions
5504 @noindent
5505 Syntax:
5506
5507 @smallexample @c ada
5508 pragma Pre (Boolean_Expression);
5509 @end smallexample
5510
5511 @noindent
5512 The @code{Pre} pragma is intended to be an exact replacement for
5513 the language-defined
5514 @code{Pre} aspect, and shares its restrictions and semantics.
5515 It must appear either immediately following the corresponding
5516 subprogram declaration (only other pragmas may intervene), or
5517 if there is no separate subprogram declaration, then it can
5518 appear at the start of the declarations in a subprogram body
5519 (preceded only by other pragmas).
5520
5521 @node Pragma Precondition
5522 @unnumberedsec Pragma Precondition
5523 @cindex Preconditions
5524 @cindex Checks, preconditions
5525 @findex Preconditions
5526 @noindent
5527 Syntax:
5528
5529 @smallexample @c ada
5530 pragma Precondition (
5531 [Check =>] Boolean_Expression
5532 [,[Message =>] String_Expression]);
5533 @end smallexample
5534
5535 @noindent
5536 The @code{Precondition} pragma is similar to @code{Postcondition}
5537 except that the corresponding checks take place immediately upon
5538 entry to the subprogram, and if a precondition fails, the exception
5539 is raised in the context of the caller, and the attribute 'Result
5540 cannot be used within the precondition expression.
5541
5542 Otherwise, the placement and visibility rules are identical to those
5543 described for postconditions. The following is an example of use
5544 within a package spec:
5545
5546 @smallexample @c ada
5547 package Math_Functions is
5548 ...
5549 function Sqrt (Arg : Float) return Float;
5550 pragma Precondition (Arg >= 0.0)
5551 ...
5552 end Math_Functions;
5553 @end smallexample
5554
5555 @noindent
5556 @code{Precondition} pragmas may appear either immediately following the
5557 (separate) declaration of a subprogram, or at the start of the
5558 declarations of a subprogram body. Only other pragmas may intervene
5559 (that is appear between the subprogram declaration and its
5560 postconditions, or appear before the postcondition in the
5561 declaration sequence in a subprogram body).
5562
5563 Note: precondition pragmas associated with subprograms that are
5564 marked as Inline_Always, or those marked as Inline with front-end
5565 inlining (-gnatN option set) are accepted and legality-checked
5566 by the compiler, but are ignored at run-time even if precondition
5567 checking is enabled.
5568
5569 Note that pragma @code{Precondition} differs from the language-defined
5570 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
5571 multiple occurrences, allowing occurences in the body even if there
5572 is a separate spec, and allowing a second string parameter, and the
5573 use of the pragma identifier @code{Check}. Historically, pragma
5574 @code{Precondition} was implemented prior to the development of
5575 Ada 2012, and has been retained in its original form for
5576 compatibility purposes.
5577
5578 @node Pragma Predicate
5579 @unnumberedsec Pragma Predicate
5580 @findex Predicate
5581 @findex Predicate pragma
5582 @noindent
5583 Syntax:
5584
5585 @smallexample @c ada
5586 pragma Predicate
5587 ([Entity =>] type_LOCAL_NAME,
5588 [Check =>] EXPRESSION);
5589 @end smallexample
5590
5591 @noindent
5592 This pragma (available in all versions of Ada in GNAT) encompasses both
5593 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5594 Ada 2012. A predicate is regarded as static if it has an allowed form
5595 for @code{Static_Predicate} and is otherwise treated as a
5596 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5597 pragma behave exactly as described in the Ada 2012 reference manual.
5598 For example, if we have
5599
5600 @smallexample @c ada
5601 type R is range 1 .. 10;
5602 subtype S is R;
5603 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5604 subtype Q is R
5605 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5606 @end smallexample
5607
5608 @noindent
5609 the effect is identical to the following Ada 2012 code:
5610
5611 @smallexample @c ada
5612 type R is range 1 .. 10;
5613 subtype S is R with
5614 Static_Predicate => S not in 4 .. 6;
5615 subtype Q is R with
5616 Dynamic_Predicate => F(Q) or G(Q);
5617 @end smallexample
5618
5619 Note that there is are no pragmas @code{Dynamic_Predicate}
5620 or @code{Static_Predicate}. That is
5621 because these pragmas would affect legality and semantics of
5622 the program and thus do not have a neutral effect if ignored.
5623 The motivation behind providing pragmas equivalent to
5624 corresponding aspects is to allow a program to be written
5625 using the pragmas, and then compiled with a compiler that
5626 will ignore the pragmas. That doesn't work in the case of
5627 static and dynamic predicates, since if the corresponding
5628 pragmas are ignored, then the behavior of the program is
5629 fundamentally changed (for example a membership test
5630 @code{A in B} would not take into account a predicate
5631 defined for subtype B). When following this approach, the
5632 use of predicates should be avoided.
5633
5634 @node Pragma Preelaborable_Initialization
5635 @unnumberedsec Pragma Preelaborable_Initialization
5636 @findex Preelaborable_Initialization
5637 @noindent
5638 Syntax:
5639
5640 @smallexample @c ada
5641 pragma Preelaborable_Initialization (DIRECT_NAME);
5642 @end smallexample
5643
5644 @noindent
5645 This pragma is standard in Ada 2005, but is available in all earlier
5646 versions of Ada as an implementation-defined pragma.
5647 See Ada 2012 Reference Manual for details.
5648
5649 @node Pragma Pre_Class
5650 @unnumberedsec Pragma Pre_Class
5651 @cindex Pre_Class
5652 @cindex Checks, preconditions
5653 @findex Preconditions
5654 @noindent
5655 Syntax:
5656
5657 @smallexample @c ada
5658 pragma Pre_Class (Boolean_Expression);
5659 @end smallexample
5660
5661 @noindent
5662 The @code{Pre_Class} pragma is intended to be an exact replacement for
5663 the language-defined
5664 @code{Pre'Class} aspect, and shares its restrictions and semantics.
5665 It must appear either immediately following the corresponding
5666 subprogram declaration (only other pragmas may intervene), or
5667 if there is no separate subprogram declaration, then it can
5668 appear at the start of the declarations in a subprogram body
5669 (preceded only by other pragmas).
5670
5671 Note: This pragma is called @code{Pre_Class} rather than
5672 @code{Pre'Class} because the latter would not be strictly
5673 conforming to the allowed syntax for pragmas. The motivation
5674 for providing pragmas equivalent to the aspects is to allow a program
5675 to be written using the pragmas, and then compiled if necessary
5676 using an Ada compiler that does not recognize the pragmas or
5677 aspects, but is prepared to ignore the pragmas. The assertion
5678 policy that controls this pragma is @code{Pre'Class}, not
5679 @code{Pre_Class}.
5680
5681 @node Pragma Priority_Specific_Dispatching
5682 @unnumberedsec Pragma Priority_Specific_Dispatching
5683 @findex Priority_Specific_Dispatching
5684 @noindent
5685 Syntax:
5686
5687 @smallexample @c ada
5688 pragma Priority_Specific_Dispatching (
5689 POLICY_IDENTIFIER,
5690 first_priority_EXPRESSION,
5691 last_priority_EXPRESSION)
5692
5693 POLICY_IDENTIFIER ::=
5694 EDF_Across_Priorities |
5695 FIFO_Within_Priorities |
5696 Non_Preemptive_Within_Priorities |
5697 Round_Robin_Within_Priorities
5698 @end smallexample
5699
5700 @noindent
5701 This pragma is standard in Ada 2005, but is available in all earlier
5702 versions of Ada as an implementation-defined pragma.
5703 See Ada 2012 Reference Manual for details.
5704
5705 @node Pragma Profile
5706 @unnumberedsec Pragma Profile
5707 @findex Profile
5708 @noindent
5709 Syntax:
5710
5711 @smallexample @c ada
5712 pragma Profile (Ravenscar | Restricted | Rational);
5713 @end smallexample
5714
5715 @noindent
5716 This pragma is standard in Ada 2005, but is available in all earlier
5717 versions of Ada as an implementation-defined pragma. This is a
5718 configuration pragma that establishes a set of configiuration pragmas
5719 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5720 The other two possibilities (@code{Restricted} or @code{Rational})
5721 are implementation-defined. The set of configuration pragmas
5722 is defined in the following sections.
5723
5724 @itemize
5725
5726 @item Pragma Profile (Ravenscar)
5727 @findex Ravenscar
5728 @noindent
5729
5730 The @code{Ravenscar} profile is standard in Ada 2005,
5731 but is available in all earlier
5732 versions of Ada as an implementation-defined pragma. This profile
5733 establishes the following set of configuration pragmas:
5734
5735 @table @code
5736 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5737 [RM D.2.2] Tasks are dispatched following a preemptive
5738 priority-ordered scheduling policy.
5739
5740 @item Locking_Policy (Ceiling_Locking)
5741 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5742 the ceiling priority of the corresponding protected object.
5743
5744 @item Detect_Blocking
5745 This pragma forces the detection of potentially blocking operations within a
5746 protected operation, and to raise Program_Error if that happens.
5747 @end table
5748 @noindent
5749
5750 plus the following set of restrictions:
5751
5752 @table @code
5753 @item Max_Entry_Queue_Length => 1
5754 No task can be queued on a protected entry.
5755 @item Max_Protected_Entries => 1
5756 @item Max_Task_Entries => 0
5757 No rendezvous statements are allowed.
5758 @item No_Abort_Statements
5759 @item No_Dynamic_Attachment
5760 @item No_Dynamic_Priorities
5761 @item No_Implicit_Heap_Allocations
5762 @item No_Local_Protected_Objects
5763 @item No_Local_Timing_Events
5764 @item No_Protected_Type_Allocators
5765 @item No_Relative_Delay
5766 @item No_Requeue_Statements
5767 @item No_Select_Statements
5768 @item No_Specific_Termination_Handlers
5769 @item No_Task_Allocators
5770 @item No_Task_Hierarchy
5771 @item No_Task_Termination
5772 @item Simple_Barriers
5773 @end table
5774 @noindent
5775
5776 The Ravenscar profile also includes the following restrictions that specify
5777 that there are no semantic dependences on the corresponding predefined
5778 packages:
5779
5780 @table @code
5781 @item No_Dependence => Ada.Asynchronous_Task_Control
5782 @item No_Dependence => Ada.Calendar
5783 @item No_Dependence => Ada.Execution_Time.Group_Budget
5784 @item No_Dependence => Ada.Execution_Time.Timers
5785 @item No_Dependence => Ada.Task_Attributes
5786 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5787 @end table
5788
5789 @noindent
5790
5791 This set of configuration pragmas and restrictions correspond to the
5792 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5793 published by the @cite{International Real-Time Ada Workshop}, 1997,
5794 and whose most recent description is available at
5795 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5796
5797 The original definition of the profile was revised at subsequent IRTAW
5798 meetings. It has been included in the ISO
5799 @cite{Guide for the Use of the Ada Programming Language in High
5800 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5801 the next revision of the standard. The formal definition given by
5802 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5803 AI-305) available at
5804 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5805 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5806
5807 The above set is a superset of the restrictions provided by pragma
5808 @code{Profile (Restricted)}, it includes six additional restrictions
5809 (@code{Simple_Barriers}, @code{No_Select_Statements},
5810 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5811 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
5812 that pragma @code{Profile (Ravenscar)}, like the pragma
5813 @code{Profile (Restricted)},
5814 automatically causes the use of a simplified,
5815 more efficient version of the tasking run-time system.
5816
5817 @item Pragma Profile (Restricted)
5818 @findex Restricted Run Time
5819 @noindent
5820 This profile corresponds to the GNAT restricted run time. It
5821 establishes the following set of restrictions:
5822
5823 @itemize @bullet
5824 @item No_Abort_Statements
5825 @item No_Entry_Queue
5826 @item No_Task_Hierarchy
5827 @item No_Task_Allocators
5828 @item No_Dynamic_Priorities
5829 @item No_Terminate_Alternatives
5830 @item No_Dynamic_Attachment
5831 @item No_Protected_Type_Allocators
5832 @item No_Local_Protected_Objects
5833 @item No_Requeue_Statements
5834 @item No_Task_Attributes_Package
5835 @item Max_Asynchronous_Select_Nesting = 0
5836 @item Max_Task_Entries = 0
5837 @item Max_Protected_Entries = 1
5838 @item Max_Select_Alternatives = 0
5839 @end itemize
5840
5841 @noindent
5842 This set of restrictions causes the automatic selection of a simplified
5843 version of the run time that provides improved performance for the
5844 limited set of tasking functionality permitted by this set of restrictions.
5845
5846 @item Pragma Profile (Rational)
5847 @findex Rational compatibility mode
5848 @noindent
5849 The Rational profile is intended to facilitate porting legacy code that
5850 compiles with the Rational APEX compiler, even when the code includes non-
5851 conforming Ada constructs. The profile enables the following three pragmas:
5852
5853 @itemize @bullet
5854 @item pragma Implicit_Packing
5855 @item pragma Overriding_Renamings
5856 @item pragma Use_VADS_Size
5857 @end itemize
5858
5859 @end itemize
5860
5861 @node Pragma Profile_Warnings
5862 @unnumberedsec Pragma Profile_Warnings
5863 @findex Profile_Warnings
5864 @noindent
5865 Syntax:
5866
5867 @smallexample @c ada
5868 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5869 @end smallexample
5870
5871 @noindent
5872 This is an implementation-defined pragma that is similar in
5873 effect to @code{pragma Profile} except that instead of
5874 generating @code{Restrictions} pragmas, it generates
5875 @code{Restriction_Warnings} pragmas. The result is that
5876 violations of the profile generate warning messages instead
5877 of error messages.
5878
5879 @node Pragma Propagate_Exceptions
5880 @unnumberedsec Pragma Propagate_Exceptions
5881 @cindex Interfacing to C++
5882 @findex Propagate_Exceptions
5883 @noindent
5884 Syntax:
5885
5886 @smallexample @c ada
5887 pragma Propagate_Exceptions;
5888 @end smallexample
5889
5890 @noindent
5891 This pragma is now obsolete and, other than generating a warning if warnings
5892 on obsolescent features are enabled, is ignored.
5893 It is retained for compatibility
5894 purposes. It used to be used in connection with optimization of
5895 a now-obsolete mechanism for implementation of exceptions.
5896
5897 @node Pragma Provide_Shift_Operators
5898 @unnumberedsec Pragma Provide_Shift_Operators
5899 @cindex Shift operators
5900 @findex Provide_Shift_Operators
5901 @noindent
5902 Syntax:
5903
5904 @smallexample @c ada
5905 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
5906 @end smallexample
5907
5908 @noindent
5909 This pragma can be applied to a first subtype local name that specifies
5910 either an unsigned or signed type. It has the effect of providing the
5911 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
5912 Rotate_Left and Rotate_Right) for the given type. It is similar to
5913 including the function declarations for these five operators, together
5914 with the pragma Import (Intrinsic, ...) statements.
5915
5916 @node Pragma Psect_Object
5917 @unnumberedsec Pragma Psect_Object
5918 @findex Psect_Object
5919 @noindent
5920 Syntax:
5921
5922 @smallexample @c ada
5923 pragma Psect_Object (
5924 [Internal =>] LOCAL_NAME,
5925 [, [External =>] EXTERNAL_SYMBOL]
5926 [, [Size =>] EXTERNAL_SYMBOL]);
5927
5928 EXTERNAL_SYMBOL ::=
5929 IDENTIFIER
5930 | static_string_EXPRESSION
5931 @end smallexample
5932
5933 @noindent
5934 This pragma is identical in effect to pragma @code{Common_Object}.
5935
5936 @node Pragma Pure_Function
5937 @unnumberedsec Pragma Pure_Function
5938 @findex Pure_Function
5939 @noindent
5940 Syntax:
5941
5942 @smallexample @c ada
5943 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5944 @end smallexample
5945
5946 @noindent
5947 This pragma appears in the same declarative part as a function
5948 declaration (or a set of function declarations if more than one
5949 overloaded declaration exists, in which case the pragma applies
5950 to all entities). It specifies that the function @code{Entity} is
5951 to be considered pure for the purposes of code generation. This means
5952 that the compiler can assume that there are no side effects, and
5953 in particular that two calls with identical arguments produce the
5954 same result. It also means that the function can be used in an
5955 address clause.
5956
5957 Note that, quite deliberately, there are no static checks to try
5958 to ensure that this promise is met, so @code{Pure_Function} can be used
5959 with functions that are conceptually pure, even if they do modify
5960 global variables. For example, a square root function that is
5961 instrumented to count the number of times it is called is still
5962 conceptually pure, and can still be optimized, even though it
5963 modifies a global variable (the count). Memo functions are another
5964 example (where a table of previous calls is kept and consulted to
5965 avoid re-computation).
5966
5967 Note also that the normal rules excluding optimization of subprograms
5968 in pure units (when parameter types are descended from System.Address,
5969 or when the full view of a parameter type is limited), do not apply
5970 for the Pure_Function case. If you explicitly specify Pure_Function,
5971 the compiler may optimize away calls with identical arguments, and
5972 if that results in unexpected behavior, the proper action is not to
5973 use the pragma for subprograms that are not (conceptually) pure.
5974
5975 @findex Pure
5976 Note: Most functions in a @code{Pure} package are automatically pure, and
5977 there is no need to use pragma @code{Pure_Function} for such functions. One
5978 exception is any function that has at least one formal of type
5979 @code{System.Address} or a type derived from it. Such functions are not
5980 considered pure by default, since the compiler assumes that the
5981 @code{Address} parameter may be functioning as a pointer and that the
5982 referenced data may change even if the address value does not.
5983 Similarly, imported functions are not considered to be pure by default,
5984 since there is no way of checking that they are in fact pure. The use
5985 of pragma @code{Pure_Function} for such a function will override these default
5986 assumption, and cause the compiler to treat a designated subprogram as pure
5987 in these cases.
5988
5989 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5990 applies to the underlying renamed function. This can be used to
5991 disambiguate cases of overloading where some but not all functions
5992 in a set of overloaded functions are to be designated as pure.
5993
5994 If pragma @code{Pure_Function} is applied to a library level function, the
5995 function is also considered pure from an optimization point of view, but the
5996 unit is not a Pure unit in the categorization sense. So for example, a function
5997 thus marked is free to @code{with} non-pure units.
5998
5999 @node Pragma Ravenscar
6000 @unnumberedsec Pragma Ravenscar
6001 @findex Pragma Ravenscar
6002 @noindent
6003 Syntax:
6004
6005 @smallexample @c ada
6006 pragma Ravenscar;
6007 @end smallexample
6008
6009 @noindent
6010 This pragma is considered obsolescent, but is retained for
6011 compatibility purposes. It is equivalent to:
6012
6013 @smallexample @c ada
6014 pragma Profile (Ravenscar);
6015 @end smallexample
6016
6017 @noindent
6018 which is the preferred method of setting the @code{Ravenscar} profile.
6019
6020 @node Pragma Refined_Depends
6021 @unnumberedsec Pragma Refined_Depends
6022 @findex Refined_Depends
6023 @noindent
6024 For the description of this pragma, see SPARK 2014 Reference Manual,
6025 section 6.1.5.
6026
6027 @node Pragma Refined_Global
6028 @unnumberedsec Pragma Refined_Global
6029 @findex Refined_Global
6030 @noindent
6031 For the description of this pragma, see SPARK 2014 Reference Manual,
6032 section 6.1.4.
6033
6034 @node Pragma Refined_Post
6035 @unnumberedsec Pragma Refined_Post
6036 @findex Refined_Post
6037 @noindent
6038 For the description of this pragma, see SPARK 2014 Reference Manual,
6039 section 7.2.7.
6040
6041 @node Pragma Refined_State
6042 @unnumberedsec Pragma Refined_State
6043 @findex Refined_State
6044 @noindent
6045 For the description of this pragma, see SPARK 2014 Reference Manual,
6046 section 7.2.2.
6047
6048 @node Pragma Relative_Deadline
6049 @unnumberedsec Pragma Relative_Deadline
6050 @findex Relative_Deadline
6051 @noindent
6052 Syntax:
6053
6054 @smallexample @c ada
6055 pragma Relative_Deadline (time_span_EXPRESSION);
6056 @end smallexample
6057
6058 @noindent
6059 This pragma is standard in Ada 2005, but is available in all earlier
6060 versions of Ada as an implementation-defined pragma.
6061 See Ada 2012 Reference Manual for details.
6062
6063 @node Pragma Remote_Access_Type
6064 @unnumberedsec Pragma Remote_Access_Type
6065 @findex Remote_Access_Type
6066 @noindent
6067 Syntax:
6068
6069 @smallexample @c ada
6070 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
6071 @end smallexample
6072
6073 @noindent
6074 This pragma appears in the formal part of a generic declaration.
6075 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
6076 the use of a remote access to class-wide type as actual for a formal
6077 access type.
6078
6079 When this pragma applies to a formal access type @code{Entity}, that
6080 type is treated as a remote access to class-wide type in the generic.
6081 It must be a formal general access type, and its designated type must
6082 be the class-wide type of a formal tagged limited private type from the
6083 same generic declaration.
6084
6085 In the generic unit, the formal type is subject to all restrictions
6086 pertaining to remote access to class-wide types. At instantiation, the
6087 actual type must be a remote access to class-wide type.
6088
6089 @node Pragma Restricted_Run_Time
6090 @unnumberedsec Pragma Restricted_Run_Time
6091 @findex Pragma Restricted_Run_Time
6092 @noindent
6093 Syntax:
6094
6095 @smallexample @c ada
6096 pragma Restricted_Run_Time;
6097 @end smallexample
6098
6099 @noindent
6100 This pragma is considered obsolescent, but is retained for
6101 compatibility purposes. It is equivalent to:
6102
6103 @smallexample @c ada
6104 pragma Profile (Restricted);
6105 @end smallexample
6106
6107 @noindent
6108 which is the preferred method of setting the restricted run time
6109 profile.
6110
6111 @node Pragma Restriction_Warnings
6112 @unnumberedsec Pragma Restriction_Warnings
6113 @findex Restriction_Warnings
6114 @noindent
6115 Syntax:
6116
6117 @smallexample @c ada
6118 pragma Restriction_Warnings
6119 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
6120 @end smallexample
6121
6122 @noindent
6123 This pragma allows a series of restriction identifiers to be
6124 specified (the list of allowed identifiers is the same as for
6125 pragma @code{Restrictions}). For each of these identifiers
6126 the compiler checks for violations of the restriction, but
6127 generates a warning message rather than an error message
6128 if the restriction is violated.
6129
6130 One use of this is in situations where you want to know
6131 about violations of a restriction, but you want to ignore some of
6132 these violations. Consider this example, where you want to set
6133 Ada_95 mode and enable style checks, but you want to know about
6134 any other use of implementation pragmas:
6135
6136 @smallexample @c ada
6137 pragma Restriction_Warnings (No_Implementation_Pragmas);
6138 pragma Warnings (Off, "violation of*No_Implementation_Pragmas*");
6139 pragma Ada_95;
6140 pragma Style_Checks ("2bfhkM160");
6141 pragma Warnings (On, "violation of*No_Implementation_Pragmas*");
6142 @end smallexample
6143
6144 @noindent
6145 By including the above lines in a configuration pragmas file,
6146 the Ada_95 and Style_Checks pragmas are accepted without
6147 generating a warning, but any other use of implementation
6148 defined pragmas will cause a warning to be generated.
6149
6150 @node Pragma Reviewable
6151 @unnumberedsec Pragma Reviewable
6152 @findex Reviewable
6153 @noindent
6154 Syntax:
6155
6156 @smallexample @c ada
6157 pragma Reviewable;
6158 @end smallexample
6159
6160 @noindent
6161 This pragma is an RM-defined standard pragma, but has no effect on the
6162 program being compiled, or on the code generated for the program.
6163
6164 To obtain the required output specified in RM H.3.1, the compiler must be
6165 run with various special switches as follows:
6166
6167 @table @i
6168
6169 @item Where compiler-generated run-time checks remain
6170
6171 The switch @option{-gnatGL}
6172 @findex @option{-gnatGL}
6173 may be used to list the expanded code in pseudo-Ada form.
6174 Runtime checks show up in the listing either as explicit
6175 checks or operators marked with @{@} to indicate a check is present.
6176
6177 @item An identification of known exceptions at compile time
6178
6179 If the program is compiled with @option{-gnatwa},
6180 @findex @option{-gnatwa}
6181 the compiler warning messages will indicate all cases where the compiler
6182 detects that an exception is certain to occur at run time.
6183
6184 @item Possible reads of uninitialized variables
6185
6186 The compiler warns of many such cases, but its output is incomplete.
6187 @ifclear FSFEDITION
6188 The CodePeer analysis tool
6189 @findex CodePeer static analysis tool
6190 @end ifclear
6191 @ifset FSFEDITION
6192 A supplemental static analysis tool
6193 @end ifset
6194 may be used to obtain a comprehensive list of all
6195 possible points at which uninitialized data may be read.
6196
6197 @item Where run-time support routines are implicitly invoked
6198
6199 In the output from @option{-gnatGL},
6200 @findex @option{-gnatGL}
6201 run-time calls are explicitly listed as calls to the relevant
6202 run-time routine.
6203
6204 @item Object code listing
6205
6206 This may be obtained either by using the @option{-S} switch,
6207 @findex @option{-S}
6208 or the objdump utility.
6209 @findex objdump
6210
6211 @item Constructs known to be erroneous at compile time
6212
6213 These are identified by warnings issued by the compiler (use @option{-gnatwa}).
6214 @findex @option{-gnatwa}
6215
6216 @item Stack usage information
6217
6218 Static stack usage data (maximum per-subprogram) can be obtained via the
6219 @option{-fstack-usage} switch to the compiler.
6220 @findex @option{-fstack-usage}
6221 Dynamic stack usage data (per task) can be obtained via the @option{-u} switch
6222 to gnatbind
6223 @findex @option{-u}
6224 @ifclear FSFEDITION
6225 The gnatstack utility
6226 @findex gnatstack
6227 can be used to provide additional information on stack usage.
6228 @end ifclear
6229
6230 @item Object code listing of entire partition
6231
6232 This can be obtained by compiling the partition with @option{-S},
6233 @findex @option{-S}
6234 or by applying objdump
6235 @findex objdump
6236 to all the object files that are part of the partition.
6237
6238 @item A description of the run-time model
6239
6240 The full sources of the run-time are available, and the documentation of
6241 these routines describes how these run-time routines interface to the
6242 underlying operating system facilities.
6243
6244 @item Control and data-flow information
6245
6246 @ifclear FSFEDITION
6247 The CodePeer tool
6248 @findex CodePeer static analysis tool
6249 @end ifclear
6250 @ifset FSFEDITION
6251 A supplemental static analysis tool
6252 @end ifset
6253 may be used to obtain complete control and data-flow information, as well as
6254 comprehensive messages identifying possible problems based on this
6255 information.
6256 @end table
6257
6258 @node Pragma Share_Generic
6259 @unnumberedsec Pragma Share_Generic
6260 @findex Share_Generic
6261 @noindent
6262 Syntax:
6263
6264 @smallexample @c ada
6265 pragma Share_Generic (GNAME @{, GNAME@});
6266
6267 GNAME ::= generic_unit_NAME | generic_instance_NAME
6268 @end smallexample
6269
6270 @noindent
6271 This pragma is provided for compatibility with Dec Ada 83. It has
6272 no effect in @code{GNAT} (which does not implement shared generics), other
6273 than to check that the given names are all names of generic units or
6274 generic instances.
6275
6276 @node Pragma Shared
6277 @unnumberedsec Pragma Shared
6278 @findex Shared
6279
6280 @noindent
6281 This pragma is provided for compatibility with Ada 83. The syntax and
6282 semantics are identical to pragma Atomic.
6283
6284 @node Pragma Short_Circuit_And_Or
6285 @unnumberedsec Pragma Short_Circuit_And_Or
6286 @findex Short_Circuit_And_Or
6287 @noindent
6288 Syntax:
6289
6290 @smallexample @c ada
6291 pragma Short_Circuit_And_Or;
6292 @end smallexample
6293
6294 @noindent
6295 This configuration pragma causes any occurrence of the AND operator applied to
6296 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
6297 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
6298 may be useful in the context of certification protocols requiring the use of
6299 short-circuited logical operators. If this configuration pragma occurs locally
6300 within the file being compiled, it applies only to the file being compiled.
6301 There is no requirement that all units in a partition use this option.
6302
6303 @node Pragma Short_Descriptors
6304 @unnumberedsec Pragma Short_Descriptors
6305 @findex Short_Descriptors
6306 @noindent
6307 Syntax:
6308
6309 @smallexample @c ada
6310 pragma Short_Descriptors
6311 @end smallexample
6312
6313 @noindent
6314 In VMS versions of the compiler, this configuration pragma causes all
6315 occurrences of the mechanism types Descriptor[_xxx] to be treated as
6316 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
6317 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
6318 versions.
6319
6320 @node Pragma Simple_Storage_Pool_Type
6321 @unnumberedsec Pragma Simple_Storage_Pool_Type
6322 @findex Simple_Storage_Pool_Type
6323 @cindex Storage pool, simple
6324 @cindex Simple storage pool
6325 @noindent
6326 Syntax:
6327
6328 @smallexample @c ada
6329 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
6330 @end smallexample
6331
6332 @noindent
6333 A type can be established as a ``simple storage pool type'' by applying
6334 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
6335 A type named in the pragma must be a library-level immutably limited record
6336 type or limited tagged type declared immediately within a package declaration.
6337 The type can also be a limited private type whose full type is allowed as
6338 a simple storage pool type.
6339
6340 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
6341 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
6342 are subtype conformant with the following subprogram declarations:
6343
6344 @smallexample @c ada
6345 procedure Allocate
6346 (Pool : in out SSP;
6347 Storage_Address : out System.Address;
6348 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6349 Alignment : System.Storage_Elements.Storage_Count);
6350
6351 procedure Deallocate
6352 (Pool : in out SSP;
6353 Storage_Address : System.Address;
6354 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6355 Alignment : System.Storage_Elements.Storage_Count);
6356
6357 function Storage_Size (Pool : SSP)
6358 return System.Storage_Elements.Storage_Count;
6359 @end smallexample
6360
6361 @noindent
6362 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
6363 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
6364 applying an unchecked deallocation has no effect other than to set its actual
6365 parameter to null. If @code{Storage_Size} is not declared, then the
6366 @code{Storage_Size} attribute applied to an access type associated with
6367 a pool object of type SSP returns zero. Additional operations can be declared
6368 for a simple storage pool type (such as for supporting a mark/release
6369 storage-management discipline).
6370
6371 An object of a simple storage pool type can be associated with an access
6372 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
6373
6374 @smallexample @c ada
6375
6376 My_Pool : My_Simple_Storage_Pool_Type;
6377
6378 type Acc is access My_Data_Type;
6379
6380 for Acc'Simple_Storage_Pool use My_Pool;
6381
6382 @end smallexample
6383
6384 @noindent
6385 See attribute @code{Simple_Storage_Pool} for further details.
6386
6387 @node Pragma Source_File_Name
6388 @unnumberedsec Pragma Source_File_Name
6389 @findex Source_File_Name
6390 @noindent
6391 Syntax:
6392
6393 @smallexample @c ada
6394 pragma Source_File_Name (
6395 [Unit_Name =>] unit_NAME,
6396 Spec_File_Name => STRING_LITERAL,
6397 [Index => INTEGER_LITERAL]);
6398
6399 pragma Source_File_Name (
6400 [Unit_Name =>] unit_NAME,
6401 Body_File_Name => STRING_LITERAL,
6402 [Index => INTEGER_LITERAL]);
6403 @end smallexample
6404
6405 @noindent
6406 Use this to override the normal naming convention. It is a configuration
6407 pragma, and so has the usual applicability of configuration pragmas
6408 (i.e.@: it applies to either an entire partition, or to all units in a
6409 compilation, or to a single unit, depending on how it is used.
6410 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
6411 the second argument is required, and indicates whether this is the file
6412 name for the spec or for the body.
6413
6414 The optional Index argument should be used when a file contains multiple
6415 units, and when you do not want to use @code{gnatchop} to separate then
6416 into multiple files (which is the recommended procedure to limit the
6417 number of recompilations that are needed when some sources change).
6418 For instance, if the source file @file{source.ada} contains
6419
6420 @smallexample @c ada
6421 package B is
6422 ...
6423 end B;
6424
6425 with B;
6426 procedure A is
6427 begin
6428 ..
6429 end A;
6430 @end smallexample
6431
6432 you could use the following configuration pragmas:
6433
6434 @smallexample @c ada
6435 pragma Source_File_Name
6436 (B, Spec_File_Name => "source.ada", Index => 1);
6437 pragma Source_File_Name
6438 (A, Body_File_Name => "source.ada", Index => 2);
6439 @end smallexample
6440
6441 Note that the @code{gnatname} utility can also be used to generate those
6442 configuration pragmas.
6443
6444 Another form of the @code{Source_File_Name} pragma allows
6445 the specification of patterns defining alternative file naming schemes
6446 to apply to all files.
6447
6448 @smallexample @c ada
6449 pragma Source_File_Name
6450 ( [Spec_File_Name =>] STRING_LITERAL
6451 [,[Casing =>] CASING_SPEC]
6452 [,[Dot_Replacement =>] STRING_LITERAL]);
6453
6454 pragma Source_File_Name
6455 ( [Body_File_Name =>] STRING_LITERAL
6456 [,[Casing =>] CASING_SPEC]
6457 [,[Dot_Replacement =>] STRING_LITERAL]);
6458
6459 pragma Source_File_Name
6460 ( [Subunit_File_Name =>] STRING_LITERAL
6461 [,[Casing =>] CASING_SPEC]
6462 [,[Dot_Replacement =>] STRING_LITERAL]);
6463
6464 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
6465 @end smallexample
6466
6467 @noindent
6468 The first argument is a pattern that contains a single asterisk indicating
6469 the point at which the unit name is to be inserted in the pattern string
6470 to form the file name. The second argument is optional. If present it
6471 specifies the casing of the unit name in the resulting file name string.
6472 The default is lower case. Finally the third argument allows for systematic
6473 replacement of any dots in the unit name by the specified string literal.
6474
6475 Note that Source_File_Name pragmas should not be used if you are using
6476 project files. The reason for this rule is that the project manager is not
6477 aware of these pragmas, and so other tools that use the projet file would not
6478 be aware of the intended naming conventions. If you are using project files,
6479 file naming is controlled by Source_File_Name_Project pragmas, which are
6480 usually supplied automatically by the project manager. A pragma
6481 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
6482
6483 For more details on the use of the @code{Source_File_Name} pragma,
6484 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
6485 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
6486 User's Guide}.
6487
6488 @node Pragma Source_File_Name_Project
6489 @unnumberedsec Pragma Source_File_Name_Project
6490 @findex Source_File_Name_Project
6491 @noindent
6492
6493 This pragma has the same syntax and semantics as pragma Source_File_Name.
6494 It is only allowed as a stand alone configuration pragma.
6495 It cannot appear after a @ref{Pragma Source_File_Name}, and
6496 most importantly, once pragma Source_File_Name_Project appears,
6497 no further Source_File_Name pragmas are allowed.
6498
6499 The intention is that Source_File_Name_Project pragmas are always
6500 generated by the Project Manager in a manner consistent with the naming
6501 specified in a project file, and when naming is controlled in this manner,
6502 it is not permissible to attempt to modify this naming scheme using
6503 Source_File_Name or Source_File_Name_Project pragmas (which would not be
6504 known to the project manager).
6505
6506 @node Pragma Source_Reference
6507 @unnumberedsec Pragma Source_Reference
6508 @findex Source_Reference
6509 @noindent
6510 Syntax:
6511
6512 @smallexample @c ada
6513 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
6514 @end smallexample
6515
6516 @noindent
6517 This pragma must appear as the first line of a source file.
6518 @var{integer_literal} is the logical line number of the line following
6519 the pragma line (for use in error messages and debugging
6520 information). @var{string_literal} is a static string constant that
6521 specifies the file name to be used in error messages and debugging
6522 information. This is most notably used for the output of @code{gnatchop}
6523 with the @option{-r} switch, to make sure that the original unchopped
6524 source file is the one referred to.
6525
6526 The second argument must be a string literal, it cannot be a static
6527 string expression other than a string literal. This is because its value
6528 is needed for error messages issued by all phases of the compiler.
6529
6530 @node Pragma SPARK_Mode
6531 @unnumberedsec Pragma SPARK_Mode
6532 @findex SPARK_Mode
6533 @noindent
6534 Syntax:
6535
6536 @smallexample @c ada
6537 pragma SPARK_Mode [(On | Off)] ;
6538 @end smallexample
6539
6540 @noindent
6541 In general a program can have some parts that are in SPARK 2014 (and
6542 follow all the rules in the SPARK Reference Manual), and some parts
6543 that are full Ada 2012.
6544
6545 The SPARK_Mode pragma is used to identify which parts are in SPARK
6546 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
6547 be used in the following places:
6548
6549 @itemize @bullet
6550
6551 @item
6552 As a configuration pragma, in which case it sets the default mode for
6553 all units compiled with this pragma.
6554
6555 @item
6556 Immediately following a library-level subprogram spec
6557
6558 @item
6559 Immediately within a library-level package body
6560
6561 @item
6562 Immediately following the @code{private} keyword of a library-level
6563 package spec
6564
6565 @item
6566 Immediately following the @code{begin} keyword of a library-level
6567 package body
6568
6569 @item
6570 Immediately within a library-level subprogram body
6571
6572 @end itemize
6573
6574 @noindent
6575 Normally a subprogram or package spec/body inherits the current mode
6576 that is active at the point it is declared. But this can be overridden
6577 by pragma within the spec or body as above.
6578
6579 The basic consistency rule is that you can't turn SPARK_Mode back
6580 @code{On}, once you have explicitly (with a pragma) turned if
6581 @code{Off}. So the following rules apply:
6582
6583 @noindent
6584 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
6585 also have SPARK_Mode @code{Off}.
6586
6587 @noindent
6588 For a package, we have four parts:
6589
6590 @itemize
6591 @item
6592 the package public declarations
6593 @item
6594 the package private part
6595 @item
6596 the body of the package
6597 @item
6598 the elaboration code after @code{begin}
6599 @end itemize
6600
6601 @noindent
6602 For a package, the rule is that if you explicitly turn SPARK_Mode
6603 @code{Off} for any part, then all the following parts must have
6604 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
6605 SPARK_Mode (@code{Off}) in the body. For example, if we have a
6606 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
6607 default everywhere, and one particular package spec has pragma
6608 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
6609 the package body.
6610
6611 @node Pragma Static_Elaboration_Desired
6612 @unnumberedsec Pragma Static_Elaboration_Desired
6613 @findex Static_Elaboration_Desired
6614 @noindent
6615 Syntax:
6616
6617 @smallexample @c ada
6618 pragma Static_Elaboration_Desired;
6619 @end smallexample
6620
6621 @noindent
6622 This pragma is used to indicate that the compiler should attempt to initialize
6623 statically the objects declared in the library unit to which the pragma applies,
6624 when these objects are initialized (explicitly or implicitly) by an aggregate.
6625 In the absence of this pragma, aggregates in object declarations are expanded
6626 into assignments and loops, even when the aggregate components are static
6627 constants. When the aggregate is present the compiler builds a static expression
6628 that requires no run-time code, so that the initialized object can be placed in
6629 read-only data space. If the components are not static, or the aggregate has
6630 more that 100 components, the compiler emits a warning that the pragma cannot
6631 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6632 construction of larger aggregates with static components that include an others
6633 choice.)
6634
6635 @node Pragma Stream_Convert
6636 @unnumberedsec Pragma Stream_Convert
6637 @findex Stream_Convert
6638 @noindent
6639 Syntax:
6640
6641 @smallexample @c ada
6642 pragma Stream_Convert (
6643 [Entity =>] type_LOCAL_NAME,
6644 [Read =>] function_NAME,
6645 [Write =>] function_NAME);
6646 @end smallexample
6647
6648 @noindent
6649 This pragma provides an efficient way of providing user-defined stream
6650 attributes. Not only is it simpler to use than specifying the attributes
6651 directly, but more importantly, it allows the specification to be made in such
6652 a way that the predefined unit Ada.Streams is not loaded unless it is actually
6653 needed (i.e. unless the stream attributes are actually used); the use of
6654 the Stream_Convert pragma adds no overhead at all, unless the stream
6655 attributes are actually used on the designated type.
6656
6657 The first argument specifies the type for which stream functions are
6658 provided. The second parameter provides a function used to read values
6659 of this type. It must name a function whose argument type may be any
6660 subtype, and whose returned type must be the type given as the first
6661 argument to the pragma.
6662
6663 The meaning of the @var{Read} parameter is that if a stream attribute directly
6664 or indirectly specifies reading of the type given as the first parameter,
6665 then a value of the type given as the argument to the Read function is
6666 read from the stream, and then the Read function is used to convert this
6667 to the required target type.
6668
6669 Similarly the @var{Write} parameter specifies how to treat write attributes
6670 that directly or indirectly apply to the type given as the first parameter.
6671 It must have an input parameter of the type specified by the first parameter,
6672 and the return type must be the same as the input type of the Read function.
6673 The effect is to first call the Write function to convert to the given stream
6674 type, and then write the result type to the stream.
6675
6676 The Read and Write functions must not be overloaded subprograms. If necessary
6677 renamings can be supplied to meet this requirement.
6678 The usage of this attribute is best illustrated by a simple example, taken
6679 from the GNAT implementation of package Ada.Strings.Unbounded:
6680
6681 @smallexample @c ada
6682 function To_Unbounded (S : String)
6683 return Unbounded_String
6684 renames To_Unbounded_String;
6685
6686 pragma Stream_Convert
6687 (Unbounded_String, To_Unbounded, To_String);
6688 @end smallexample
6689
6690 @noindent
6691 The specifications of the referenced functions, as given in the Ada
6692 Reference Manual are:
6693
6694 @smallexample @c ada
6695 function To_Unbounded_String (Source : String)
6696 return Unbounded_String;
6697
6698 function To_String (Source : Unbounded_String)
6699 return String;
6700 @end smallexample
6701
6702 @noindent
6703 The effect is that if the value of an unbounded string is written to a stream,
6704 then the representation of the item in the stream is in the same format that
6705 would be used for @code{Standard.String'Output}, and this same representation
6706 is expected when a value of this type is read from the stream. Note that the
6707 value written always includes the bounds, even for Unbounded_String'Write,
6708 since Unbounded_String is not an array type.
6709
6710 Note that the @code{Stream_Convert} pragma is not effective in the case of
6711 a derived type of a non-limited tagged type. If such a type is specified then
6712 the pragma is silently ignored, and the default implementation of the stream
6713 attributes is used instead.
6714
6715 @node Pragma Style_Checks
6716 @unnumberedsec Pragma Style_Checks
6717 @findex Style_Checks
6718 @noindent
6719 Syntax:
6720
6721 @smallexample @c ada
6722 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6723 On | Off [, LOCAL_NAME]);
6724 @end smallexample
6725
6726 @noindent
6727 This pragma is used in conjunction with compiler switches to control the
6728 built in style checking provided by GNAT@. The compiler switches, if set,
6729 provide an initial setting for the switches, and this pragma may be used
6730 to modify these settings, or the settings may be provided entirely by
6731 the use of the pragma. This pragma can be used anywhere that a pragma
6732 is legal, including use as a configuration pragma (including use in
6733 the @file{gnat.adc} file).
6734
6735 The form with a string literal specifies which style options are to be
6736 activated. These are additive, so they apply in addition to any previously
6737 set style check options. The codes for the options are the same as those
6738 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6739 For example the following two methods can be used to enable
6740 layout checking:
6741
6742 @itemize @bullet
6743 @item
6744 @smallexample @c ada
6745 pragma Style_Checks ("l");
6746 @end smallexample
6747
6748 @item
6749 @smallexample
6750 gcc -c -gnatyl @dots{}
6751 @end smallexample
6752 @end itemize
6753
6754 @noindent
6755 The form ALL_CHECKS activates all standard checks (its use is equivalent
6756 to the use of the @code{gnaty} switch with no options. @xref{Top,
6757 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6758 @value{EDITION} User's Guide}, for details.)
6759
6760 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6761 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6762 options (i.e. equivalent to -gnatyg).
6763
6764 The forms with @code{Off} and @code{On}
6765 can be used to temporarily disable style checks
6766 as shown in the following example:
6767
6768 @smallexample @c ada
6769 @iftex
6770 @leftskip=0cm
6771 @end iftex
6772 pragma Style_Checks ("k"); -- requires keywords in lower case
6773 pragma Style_Checks (Off); -- turn off style checks
6774 NULL; -- this will not generate an error message
6775 pragma Style_Checks (On); -- turn style checks back on
6776 NULL; -- this will generate an error message
6777 @end smallexample
6778
6779 @noindent
6780 Finally the two argument form is allowed only if the first argument is
6781 @code{On} or @code{Off}. The effect is to turn of semantic style checks
6782 for the specified entity, as shown in the following example:
6783
6784 @smallexample @c ada
6785 @iftex
6786 @leftskip=0cm
6787 @end iftex
6788 pragma Style_Checks ("r"); -- require consistency of identifier casing
6789 Arg : Integer;
6790 Rf1 : Integer := ARG; -- incorrect, wrong case
6791 pragma Style_Checks (Off, Arg);
6792 Rf2 : Integer := ARG; -- OK, no error
6793 @end smallexample
6794
6795 @node Pragma Subtitle
6796 @unnumberedsec Pragma Subtitle
6797 @findex Subtitle
6798 @noindent
6799 Syntax:
6800
6801 @smallexample @c ada
6802 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6803 @end smallexample
6804
6805 @noindent
6806 This pragma is recognized for compatibility with other Ada compilers
6807 but is ignored by GNAT@.
6808
6809 @node Pragma Suppress
6810 @unnumberedsec Pragma Suppress
6811 @findex Suppress
6812 @noindent
6813 Syntax:
6814
6815 @smallexample @c ada
6816 pragma Suppress (Identifier [, [On =>] Name]);
6817 @end smallexample
6818
6819 @noindent
6820 This is a standard pragma, and supports all the check names required in
6821 the RM. It is included here because GNAT recognizes some additional check
6822 names that are implementation defined (as permitted by the RM):
6823
6824 @itemize @bullet
6825
6826 @item
6827 @code{Alignment_Check} can be used to suppress alignment checks
6828 on addresses used in address clauses. Such checks can also be suppressed
6829 by suppressing range checks, but the specific use of @code{Alignment_Check}
6830 allows suppression of alignment checks without suppressing other range checks.
6831
6832 @item
6833 @code{Atomic_Synchronization} can be used to suppress the special memory
6834 synchronization instructions that are normally generated for access to
6835 @code{Atomic} variables to ensure correct synchronization between tasks
6836 that use such variables for synchronization purposes.
6837
6838 @item
6839 @code{Duplicated_Tag_Check} Can be used to suppress the check that is generated
6840 for a duplicated tag value when a tagged type is declared.
6841
6842 @item
6843 @code{Predicate_Check} can be used to control whether predicate checks are
6844 active. It is applicable only to predicates for which the policy is
6845 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6846 predicate is ignored or checked for the whole program, the use of
6847 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6848 predicate to be turned on and off at specific points in the program.
6849
6850 @item
6851 @code{Validity_Check} can be used specifically to control validity checks.
6852 If @code{Suppress} is used to suppress validity checks, then no validity
6853 checks are performed, including those specified by the appropriate compiler
6854 switch or the @code{Validity_Checks} pragma.
6855
6856 @item
6857 Additional check names previously introduced by use of the @code{Check_Name}
6858 pragma are also allowed.
6859
6860 @end itemize
6861
6862 @noindent
6863 Note that pragma Suppress gives the compiler permission to omit
6864 checks, but does not require the compiler to omit checks. The compiler
6865 will generate checks if they are essentially free, even when they are
6866 suppressed. In particular, if the compiler can prove that a certain
6867 check will necessarily fail, it will generate code to do an
6868 unconditional ``raise'', even if checks are suppressed. The compiler
6869 warns in this case.
6870
6871 Of course, run-time checks are omitted whenever the compiler can prove
6872 that they will not fail, whether or not checks are suppressed.
6873
6874 @node Pragma Suppress_All
6875 @unnumberedsec Pragma Suppress_All
6876 @findex Suppress_All
6877 @noindent
6878 Syntax:
6879
6880 @smallexample @c ada
6881 pragma Suppress_All;
6882 @end smallexample
6883
6884 @noindent
6885 This pragma can appear anywhere within a unit.
6886 The effect is to apply @code{Suppress (All_Checks)} to the unit
6887 in which it appears. This pragma is implemented for compatibility with DEC
6888 Ada 83 usage where it appears at the end of a unit, and for compatibility
6889 with Rational Ada, where it appears as a program unit pragma.
6890 The use of the standard Ada pragma @code{Suppress (All_Checks)}
6891 as a normal configuration pragma is the preferred usage in GNAT@.
6892
6893 @node Pragma Suppress_Debug_Info
6894 @unnumberedsec Pragma Suppress_Debug_Info
6895 @findex Suppress_Debug_Info
6896 @noindent
6897 Syntax:
6898
6899 @smallexample @c ada
6900 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
6901 @end smallexample
6902
6903 @noindent
6904 This pragma can be used to suppress generation of debug information
6905 for the specified entity. It is intended primarily for use in debugging
6906 the debugger, and navigating around debugger problems.
6907
6908 @node Pragma Suppress_Exception_Locations
6909 @unnumberedsec Pragma Suppress_Exception_Locations
6910 @findex Suppress_Exception_Locations
6911 @noindent
6912 Syntax:
6913
6914 @smallexample @c ada
6915 pragma Suppress_Exception_Locations;
6916 @end smallexample
6917
6918 @noindent
6919 In normal mode, a raise statement for an exception by default generates
6920 an exception message giving the file name and line number for the location
6921 of the raise. This is useful for debugging and logging purposes, but this
6922 entails extra space for the strings for the messages. The configuration
6923 pragma @code{Suppress_Exception_Locations} can be used to suppress the
6924 generation of these strings, with the result that space is saved, but the
6925 exception message for such raises is null. This configuration pragma may
6926 appear in a global configuration pragma file, or in a specific unit as
6927 usual. It is not required that this pragma be used consistently within
6928 a partition, so it is fine to have some units within a partition compiled
6929 with this pragma and others compiled in normal mode without it.
6930
6931 @node Pragma Suppress_Initialization
6932 @unnumberedsec Pragma Suppress_Initialization
6933 @findex Suppress_Initialization
6934 @cindex Suppressing initialization
6935 @cindex Initialization, suppression of
6936 @noindent
6937 Syntax:
6938
6939 @smallexample @c ada
6940 pragma Suppress_Initialization ([Entity =>] subtype_Name);
6941 @end smallexample
6942
6943 @noindent
6944 Here subtype_Name is the name introduced by a type declaration
6945 or subtype declaration.
6946 This pragma suppresses any implicit or explicit initialization
6947 for all variables of the given type or subtype,
6948 including initialization resulting from the use of pragmas
6949 Normalize_Scalars or Initialize_Scalars.
6950
6951 This is considered a representation item, so it cannot be given after
6952 the type is frozen. It applies to all subsequent object declarations,
6953 and also any allocator that creates objects of the type.
6954
6955 If the pragma is given for the first subtype, then it is considered
6956 to apply to the base type and all its subtypes. If the pragma is given
6957 for other than a first subtype, then it applies only to the given subtype.
6958 The pragma may not be given after the type is frozen.
6959
6960 Note that this includes eliminating initialization of discriminants
6961 for discriminated types, and tags for tagged types. In these cases,
6962 you will have to use some non-portable mechanism (e.g. address
6963 overlays or unchecked conversion) to achieve required initialization
6964 of these fields before accessing any object of the corresponding type.
6965
6966 @node Pragma Task_Name
6967 @unnumberedsec Pragma Task_Name
6968 @findex Task_Name
6969 @noindent
6970 Syntax
6971
6972 @smallexample @c ada
6973 pragma Task_Name (string_EXPRESSION);
6974 @end smallexample
6975
6976 @noindent
6977 This pragma appears within a task definition (like pragma
6978 @code{Priority}) and applies to the task in which it appears. The
6979 argument must be of type String, and provides a name to be used for
6980 the task instance when the task is created. Note that this expression
6981 is not required to be static, and in particular, it can contain
6982 references to task discriminants. This facility can be used to
6983 provide different names for different tasks as they are created,
6984 as illustrated in the example below.
6985
6986 The task name is recorded internally in the run-time structures
6987 and is accessible to tools like the debugger. In addition the
6988 routine @code{Ada.Task_Identification.Image} will return this
6989 string, with a unique task address appended.
6990
6991 @smallexample @c ada
6992 -- Example of the use of pragma Task_Name
6993
6994 with Ada.Task_Identification;
6995 use Ada.Task_Identification;
6996 with Text_IO; use Text_IO;
6997 procedure t3 is
6998
6999 type Astring is access String;
7000
7001 task type Task_Typ (Name : access String) is
7002 pragma Task_Name (Name.all);
7003 end Task_Typ;
7004
7005 task body Task_Typ is
7006 Nam : constant String := Image (Current_Task);
7007 begin
7008 Put_Line ("-->" & Nam (1 .. 14) & "<--");
7009 end Task_Typ;
7010
7011 type Ptr_Task is access Task_Typ;
7012 Task_Var : Ptr_Task;
7013
7014 begin
7015 Task_Var :=
7016 new Task_Typ (new String'("This is task 1"));
7017 Task_Var :=
7018 new Task_Typ (new String'("This is task 2"));
7019 end;
7020 @end smallexample
7021
7022 @node Pragma Task_Storage
7023 @unnumberedsec Pragma Task_Storage
7024 @findex Task_Storage
7025 Syntax:
7026
7027 @smallexample @c ada
7028 pragma Task_Storage (
7029 [Task_Type =>] LOCAL_NAME,
7030 [Top_Guard =>] static_integer_EXPRESSION);
7031 @end smallexample
7032
7033 @noindent
7034 This pragma specifies the length of the guard area for tasks. The guard
7035 area is an additional storage area allocated to a task. A value of zero
7036 means that either no guard area is created or a minimal guard area is
7037 created, depending on the target. This pragma can appear anywhere a
7038 @code{Storage_Size} attribute definition clause is allowed for a task
7039 type.
7040
7041 @node Pragma Test_Case
7042 @unnumberedsec Pragma Test_Case
7043 @cindex Test cases
7044 @findex Test_Case
7045 @noindent
7046 Syntax:
7047
7048 @smallexample @c ada
7049 pragma Test_Case (
7050 [Name =>] static_string_Expression
7051 ,[Mode =>] (Nominal | Robustness)
7052 [, Requires => Boolean_Expression]
7053 [, Ensures => Boolean_Expression]);
7054 @end smallexample
7055
7056 @noindent
7057 The @code{Test_Case} pragma allows defining fine-grain specifications
7058 for use by testing tools.
7059 The compiler checks the validity of the @code{Test_Case} pragma, but its
7060 presence does not lead to any modification of the code generated by the
7061 compiler.
7062
7063 @code{Test_Case} pragmas may only appear immediately following the
7064 (separate) declaration of a subprogram in a package declaration, inside
7065 a package spec unit. Only other pragmas may intervene (that is appear
7066 between the subprogram declaration and a test case).
7067
7068 The compiler checks that boolean expressions given in @code{Requires} and
7069 @code{Ensures} are valid, where the rules for @code{Requires} are the
7070 same as the rule for an expression in @code{Precondition} and the rules
7071 for @code{Ensures} are the same as the rule for an expression in
7072 @code{Postcondition}. In particular, attributes @code{'Old} and
7073 @code{'Result} can only be used within the @code{Ensures}
7074 expression. The following is an example of use within a package spec:
7075
7076 @smallexample @c ada
7077 package Math_Functions is
7078 ...
7079 function Sqrt (Arg : Float) return Float;
7080 pragma Test_Case (Name => "Test 1",
7081 Mode => Nominal,
7082 Requires => Arg < 10000,
7083 Ensures => Sqrt'Result < 10);
7084 ...
7085 end Math_Functions;
7086 @end smallexample
7087
7088 @noindent
7089 The meaning of a test case is that there is at least one context where
7090 @code{Requires} holds such that, if the associated subprogram is executed in
7091 that context, then @code{Ensures} holds when the subprogram returns.
7092 Mode @code{Nominal} indicates that the input context should also satisfy the
7093 precondition of the subprogram, and the output context should also satisfy its
7094 postcondition. More @code{Robustness} indicates that the precondition and
7095 postcondition of the subprogram should be ignored for this test case.
7096
7097 @node Pragma Thread_Local_Storage
7098 @unnumberedsec Pragma Thread_Local_Storage
7099 @findex Thread_Local_Storage
7100 @cindex Task specific storage
7101 @cindex TLS (Thread Local Storage)
7102 @cindex Task_Attributes
7103 Syntax:
7104
7105 @smallexample @c ada
7106 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
7107 @end smallexample
7108
7109 @noindent
7110 This pragma specifies that the specified entity, which must be
7111 a variable declared in a library level package, is to be marked as
7112 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
7113 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
7114 (and hence each Ada task) to see a distinct copy of the variable.
7115
7116 The variable may not have default initialization, and if there is
7117 an explicit initialization, it must be either @code{null} for an
7118 access variable, or a static expression for a scalar variable.
7119 This provides a low level mechanism similar to that provided by
7120 the @code{Ada.Task_Attributes} package, but much more efficient
7121 and is also useful in writing interface code that will interact
7122 with foreign threads.
7123
7124 If this pragma is used on a system where @code{TLS} is not supported,
7125 then an error message will be generated and the program will be rejected.
7126
7127 @node Pragma Time_Slice
7128 @unnumberedsec Pragma Time_Slice
7129 @findex Time_Slice
7130 @noindent
7131 Syntax:
7132
7133 @smallexample @c ada
7134 pragma Time_Slice (static_duration_EXPRESSION);
7135 @end smallexample
7136
7137 @noindent
7138 For implementations of GNAT on operating systems where it is possible
7139 to supply a time slice value, this pragma may be used for this purpose.
7140 It is ignored if it is used in a system that does not allow this control,
7141 or if it appears in other than the main program unit.
7142 @cindex OpenVMS
7143 Note that the effect of this pragma is identical to the effect of the
7144 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
7145
7146 @node Pragma Title
7147 @unnumberedsec Pragma Title
7148 @findex Title
7149 @noindent
7150 Syntax:
7151
7152 @smallexample @c ada
7153 pragma Title (TITLING_OPTION [, TITLING OPTION]);
7154
7155 TITLING_OPTION ::=
7156 [Title =>] STRING_LITERAL,
7157 | [Subtitle =>] STRING_LITERAL
7158 @end smallexample
7159
7160 @noindent
7161 Syntax checked but otherwise ignored by GNAT@. This is a listing control
7162 pragma used in DEC Ada 83 implementations to provide a title and/or
7163 subtitle for the program listing. The program listing generated by GNAT
7164 does not have titles or subtitles.
7165
7166 Unlike other pragmas, the full flexibility of named notation is allowed
7167 for this pragma, i.e.@: the parameters may be given in any order if named
7168 notation is used, and named and positional notation can be mixed
7169 following the normal rules for procedure calls in Ada.
7170
7171 @node Pragma Type_Invariant
7172 @unnumberedsec Pragma Type_Invariant
7173 @findex Invariant
7174 @findex Type_Invariant pragma
7175 @noindent
7176 Syntax:
7177
7178 @smallexample @c ada
7179 pragma Type_Invariant
7180 ([Entity =>] type_LOCAL_NAME,
7181 [Check =>] EXPRESSION);
7182 @end smallexample
7183
7184 @noindent
7185 The @code{Type_Invariant} pragma is intended to be an exact
7186 replacement for the language-defined @code{Type_Invariant}
7187 aspect, and shares its restrictions and semantics. It differs
7188 from the language defined @code{Invariant} pragma in that it
7189 does not permit a string parameter, and it is
7190 controlled by the assertion identifier @code{Type_Invariant}
7191 rather than @code{Invariant}.
7192
7193 @node Pragma Type_Invariant_Class
7194 @unnumberedsec Pragma Type_Invariant_Class
7195 @findex Invariant
7196 @findex Type_Invariant_Class pragma
7197 @noindent
7198 Syntax:
7199
7200 @smallexample @c ada
7201 pragma Type_Invariant_Class
7202 ([Entity =>] type_LOCAL_NAME,
7203 [Check =>] EXPRESSION);
7204 @end smallexample
7205
7206 @noindent
7207 The @code{Type_Invariant_Class} pragma is intended to be an exact
7208 replacement for the language-defined @code{Type_Invariant'Class}
7209 aspect, and shares its restrictions and semantics.
7210
7211 Note: This pragma is called @code{Type_Invariant_Class} rather than
7212 @code{Type_Invariant'Class} because the latter would not be strictly
7213 conforming to the allowed syntax for pragmas. The motivation
7214 for providing pragmas equivalent to the aspects is to allow a program
7215 to be written using the pragmas, and then compiled if necessary
7216 using an Ada compiler that does not recognize the pragmas or
7217 aspects, but is prepared to ignore the pragmas. The assertion
7218 policy that controls this pragma is @code{Type_Invariant'Class},
7219 not @code{Type_Invariant_Class}.
7220
7221 @node Pragma Unchecked_Union
7222 @unnumberedsec Pragma Unchecked_Union
7223 @cindex Unions in C
7224 @findex Unchecked_Union
7225 @noindent
7226 Syntax:
7227
7228 @smallexample @c ada
7229 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
7230 @end smallexample
7231
7232 @noindent
7233 This pragma is used to specify a representation of a record type that is
7234 equivalent to a C union. It was introduced as a GNAT implementation defined
7235 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
7236 pragma, making it language defined, and GNAT fully implements this extended
7237 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
7238 details, consult the Ada 2012 Reference Manual, section B.3.3.
7239
7240 @node Pragma Unimplemented_Unit
7241 @unnumberedsec Pragma Unimplemented_Unit
7242 @findex Unimplemented_Unit
7243 @noindent
7244 Syntax:
7245
7246 @smallexample @c ada
7247 pragma Unimplemented_Unit;
7248 @end smallexample
7249
7250 @noindent
7251 If this pragma occurs in a unit that is processed by the compiler, GNAT
7252 aborts with the message @samp{@var{xxx} not implemented}, where
7253 @var{xxx} is the name of the current compilation unit. This pragma is
7254 intended to allow the compiler to handle unimplemented library units in
7255 a clean manner.
7256
7257 The abort only happens if code is being generated. Thus you can use
7258 specs of unimplemented packages in syntax or semantic checking mode.
7259
7260 @node Pragma Universal_Aliasing
7261 @unnumberedsec Pragma Universal_Aliasing
7262 @findex Universal_Aliasing
7263 @noindent
7264 Syntax:
7265
7266 @smallexample @c ada
7267 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
7268 @end smallexample
7269
7270 @noindent
7271 @var{type_LOCAL_NAME} must refer to a type declaration in the current
7272 declarative part. The effect is to inhibit strict type-based aliasing
7273 optimization for the given type. In other words, the effect is as though
7274 access types designating this type were subject to pragma No_Strict_Aliasing.
7275 For a detailed description of the strict aliasing optimization, and the
7276 situations in which it must be suppressed, @xref{Optimization and Strict
7277 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
7278
7279 @node Pragma Universal_Data
7280 @unnumberedsec Pragma Universal_Data
7281 @findex Universal_Data
7282 @noindent
7283 Syntax:
7284
7285 @smallexample @c ada
7286 pragma Universal_Data [(library_unit_Name)];
7287 @end smallexample
7288
7289 @noindent
7290 This pragma is supported only for the AAMP target and is ignored for
7291 other targets. The pragma specifies that all library-level objects
7292 (Counter 0 data) associated with the library unit are to be accessed
7293 and updated using universal addressing (24-bit addresses for AAMP5)
7294 rather than the default of 16-bit Data Environment (DENV) addressing.
7295 Use of this pragma will generally result in less efficient code for
7296 references to global data associated with the library unit, but
7297 allows such data to be located anywhere in memory. This pragma is
7298 a library unit pragma, but can also be used as a configuration pragma
7299 (including use in the @file{gnat.adc} file). The functionality
7300 of this pragma is also available by applying the -univ switch on the
7301 compilations of units where universal addressing of the data is desired.
7302
7303 @node Pragma Unmodified
7304 @unnumberedsec Pragma Unmodified
7305 @findex Unmodified
7306 @cindex Warnings, unmodified
7307 @noindent
7308 Syntax:
7309
7310 @smallexample @c ada
7311 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
7312 @end smallexample
7313
7314 @noindent
7315 This pragma signals that the assignable entities (variables,
7316 @code{out} parameters, @code{in out} parameters) whose names are listed are
7317 deliberately not assigned in the current source unit. This
7318 suppresses warnings about the
7319 entities being referenced but not assigned, and in addition a warning will be
7320 generated if one of these entities is in fact assigned in the
7321 same unit as the pragma (or in the corresponding body, or one
7322 of its subunits).
7323
7324 This is particularly useful for clearly signaling that a particular
7325 parameter is not modified, even though the spec suggests that it might
7326 be.
7327
7328 For the variable case, warnings are never given for unreferenced variables
7329 whose name contains one of the substrings
7330 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7331 are typically to be used in cases where such warnings are expected.
7332 Thus it is never necessary to use @code{pragma Unmodified} for such
7333 variables, though it is harmless to do so.
7334
7335 @node Pragma Unreferenced
7336 @unnumberedsec Pragma Unreferenced
7337 @findex Unreferenced
7338 @cindex Warnings, unreferenced
7339 @noindent
7340 Syntax:
7341
7342 @smallexample @c ada
7343 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
7344 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
7345 @end smallexample
7346
7347 @noindent
7348 This pragma signals that the entities whose names are listed are
7349 deliberately not referenced in the current source unit after the
7350 occurrence of the pragma. This
7351 suppresses warnings about the
7352 entities being unreferenced, and in addition a warning will be
7353 generated if one of these entities is in fact subsequently referenced in the
7354 same unit as the pragma (or in the corresponding body, or one
7355 of its subunits).
7356
7357 This is particularly useful for clearly signaling that a particular
7358 parameter is not referenced in some particular subprogram implementation
7359 and that this is deliberate. It can also be useful in the case of
7360 objects declared only for their initialization or finalization side
7361 effects.
7362
7363 If @code{LOCAL_NAME} identifies more than one matching homonym in the
7364 current scope, then the entity most recently declared is the one to which
7365 the pragma applies. Note that in the case of accept formals, the pragma
7366 Unreferenced may appear immediately after the keyword @code{do} which
7367 allows the indication of whether or not accept formals are referenced
7368 or not to be given individually for each accept statement.
7369
7370 The left hand side of an assignment does not count as a reference for the
7371 purpose of this pragma. Thus it is fine to assign to an entity for which
7372 pragma Unreferenced is given.
7373
7374 Note that if a warning is desired for all calls to a given subprogram,
7375 regardless of whether they occur in the same unit as the subprogram
7376 declaration, then this pragma should not be used (calls from another
7377 unit would not be flagged); pragma Obsolescent can be used instead
7378 for this purpose, see @xref{Pragma Obsolescent}.
7379
7380 The second form of pragma @code{Unreferenced} is used within a context
7381 clause. In this case the arguments must be unit names of units previously
7382 mentioned in @code{with} clauses (similar to the usage of pragma
7383 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
7384 units and unreferenced entities within these units.
7385
7386 For the variable case, warnings are never given for unreferenced variables
7387 whose name contains one of the substrings
7388 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7389 are typically to be used in cases where such warnings are expected.
7390 Thus it is never necessary to use @code{pragma Unreferenced} for such
7391 variables, though it is harmless to do so.
7392
7393 @node Pragma Unreferenced_Objects
7394 @unnumberedsec Pragma Unreferenced_Objects
7395 @findex Unreferenced_Objects
7396 @cindex Warnings, unreferenced
7397 @noindent
7398 Syntax:
7399
7400 @smallexample @c ada
7401 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
7402 @end smallexample
7403
7404 @noindent
7405 This pragma signals that for the types or subtypes whose names are
7406 listed, objects which are declared with one of these types or subtypes may
7407 not be referenced, and if no references appear, no warnings are given.
7408
7409 This is particularly useful for objects which are declared solely for their
7410 initialization and finalization effect. Such variables are sometimes referred
7411 to as RAII variables (Resource Acquisition Is Initialization). Using this
7412 pragma on the relevant type (most typically a limited controlled type), the
7413 compiler will automatically suppress unwanted warnings about these variables
7414 not being referenced.
7415
7416 @node Pragma Unreserve_All_Interrupts
7417 @unnumberedsec Pragma Unreserve_All_Interrupts
7418 @findex Unreserve_All_Interrupts
7419 @noindent
7420 Syntax:
7421
7422 @smallexample @c ada
7423 pragma Unreserve_All_Interrupts;
7424 @end smallexample
7425
7426 @noindent
7427 Normally certain interrupts are reserved to the implementation. Any attempt
7428 to attach an interrupt causes Program_Error to be raised, as described in
7429 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
7430 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
7431 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
7432 interrupt execution.
7433
7434 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
7435 a program, then all such interrupts are unreserved. This allows the
7436 program to handle these interrupts, but disables their standard
7437 functions. For example, if this pragma is used, then pressing
7438 @kbd{Ctrl-C} will not automatically interrupt execution. However,
7439 a program can then handle the @code{SIGINT} interrupt as it chooses.
7440
7441 For a full list of the interrupts handled in a specific implementation,
7442 see the source code for the spec of @code{Ada.Interrupts.Names} in
7443 file @file{a-intnam.ads}. This is a target dependent file that contains the
7444 list of interrupts recognized for a given target. The documentation in
7445 this file also specifies what interrupts are affected by the use of
7446 the @code{Unreserve_All_Interrupts} pragma.
7447
7448 For a more general facility for controlling what interrupts can be
7449 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
7450 of the @code{Unreserve_All_Interrupts} pragma.
7451
7452 @node Pragma Unsuppress
7453 @unnumberedsec Pragma Unsuppress
7454 @findex Unsuppress
7455 @noindent
7456 Syntax:
7457
7458 @smallexample @c ada
7459 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
7460 @end smallexample
7461
7462 @noindent
7463 This pragma undoes the effect of a previous pragma @code{Suppress}. If
7464 there is no corresponding pragma @code{Suppress} in effect, it has no
7465 effect. The range of the effect is the same as for pragma
7466 @code{Suppress}. The meaning of the arguments is identical to that used
7467 in pragma @code{Suppress}.
7468
7469 One important application is to ensure that checks are on in cases where
7470 code depends on the checks for its correct functioning, so that the code
7471 will compile correctly even if the compiler switches are set to suppress
7472 checks. For example, in a program that depends on external names of tagged
7473 types and wants to ensure that the duplicated tag check occurs even if all
7474 run-time checks are suppressed by a compiler switch, the following
7475 configuration pragma will ensure this test is not suppressed:
7476
7477 @smallexample @c ada
7478 pragma Unsuppress (Duplicated_Tag_Check);
7479 @end smallexample
7480
7481 @noindent
7482 This pragma is standard in Ada 2005. It is available in all earlier versions
7483 of Ada as an implementation-defined pragma.
7484
7485 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
7486 a number of implementation-defined check names. See description of pragma
7487 @code{Suppress} for full details.
7488
7489 @node Pragma Use_VADS_Size
7490 @unnumberedsec Pragma Use_VADS_Size
7491 @cindex @code{Size}, VADS compatibility
7492 @cindex Rational profile
7493 @findex Use_VADS_Size
7494 @noindent
7495 Syntax:
7496
7497 @smallexample @c ada
7498 pragma Use_VADS_Size;
7499 @end smallexample
7500
7501 @noindent
7502 This is a configuration pragma. In a unit to which it applies, any use
7503 of the 'Size attribute is automatically interpreted as a use of the
7504 'VADS_Size attribute. Note that this may result in incorrect semantic
7505 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
7506 the handling of existing code which depends on the interpretation of Size
7507 as implemented in the VADS compiler. See description of the VADS_Size
7508 attribute for further details.
7509
7510 @node Pragma Validity_Checks
7511 @unnumberedsec Pragma Validity_Checks
7512 @findex Validity_Checks
7513 @noindent
7514 Syntax:
7515
7516 @smallexample @c ada
7517 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
7518 @end smallexample
7519
7520 @noindent
7521 This pragma is used in conjunction with compiler switches to control the
7522 built-in validity checking provided by GNAT@. The compiler switches, if set
7523 provide an initial setting for the switches, and this pragma may be used
7524 to modify these settings, or the settings may be provided entirely by
7525 the use of the pragma. This pragma can be used anywhere that a pragma
7526 is legal, including use as a configuration pragma (including use in
7527 the @file{gnat.adc} file).
7528
7529 The form with a string literal specifies which validity options are to be
7530 activated. The validity checks are first set to include only the default
7531 reference manual settings, and then a string of letters in the string
7532 specifies the exact set of options required. The form of this string
7533 is exactly as described for the @option{-gnatVx} compiler switch (see the
7534 @value{EDITION} User's Guide for details). For example the following two
7535 methods can be used to enable validity checking for mode @code{in} and
7536 @code{in out} subprogram parameters:
7537
7538 @itemize @bullet
7539 @item
7540 @smallexample @c ada
7541 pragma Validity_Checks ("im");
7542 @end smallexample
7543
7544 @item
7545 @smallexample
7546 gcc -c -gnatVim @dots{}
7547 @end smallexample
7548 @end itemize
7549
7550 @noindent
7551 The form ALL_CHECKS activates all standard checks (its use is equivalent
7552 to the use of the @code{gnatva} switch.
7553
7554 The forms with @code{Off} and @code{On}
7555 can be used to temporarily disable validity checks
7556 as shown in the following example:
7557
7558 @smallexample @c ada
7559 @iftex
7560 @leftskip=0cm
7561 @end iftex
7562 pragma Validity_Checks ("c"); -- validity checks for copies
7563 pragma Validity_Checks (Off); -- turn off validity checks
7564 A := B; -- B will not be validity checked
7565 pragma Validity_Checks (On); -- turn validity checks back on
7566 A := C; -- C will be validity checked
7567 @end smallexample
7568
7569 @node Pragma Volatile
7570 @unnumberedsec Pragma Volatile
7571 @findex Volatile
7572 @noindent
7573 Syntax:
7574
7575 @smallexample @c ada
7576 pragma Volatile (LOCAL_NAME);
7577 @end smallexample
7578
7579 @noindent
7580 This pragma is defined by the Ada Reference Manual, and the GNAT
7581 implementation is fully conformant with this definition. The reason it
7582 is mentioned in this section is that a pragma of the same name was supplied
7583 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
7584 implementation of pragma Volatile is upwards compatible with the
7585 implementation in DEC Ada 83.
7586
7587 @node Pragma Warning_As_Error
7588 @unnumberedsec Pragma Warning_As_Error
7589 @findex Warning_As_Error
7590 @noindent
7591 Syntax:
7592
7593 @smallexample @c ada
7594 pragma Warning_As_Error (static_string_EXPRESSION);
7595 @end smallexample
7596
7597 @noindent
7598 This configuration pragma allows the programmer to specify a set
7599 of warnings that will be treated as errors. Any warning which
7600 matches the pattern given by the pragma argument will be treated
7601 as an error. This gives much more precise control that -gnatwe
7602 which treats all warnings as errors.
7603
7604 The pattern may contain asterisks, which match zero or more characters in
7605 the message. For example, you can use
7606 @code{pragma Warning_As_Error ("bits of*unused")} to treat the warning
7607 message @code{warning: 960 bits of "a" unused} as an error. No other regular
7608 expression notations are permitted. All characters other than asterisk in
7609 these three specific cases are treated as literal characters in the match.
7610 The match is case insensitive, for example XYZ matches xyz.
7611
7612 Note that the pattern matches if it occurs anywhere within the warning
7613 message string (it is not necessary to put an asterisk at the start and
7614 the end of the message, since this is implied).
7615
7616 Another possibility for the static_string_EXPRESSION which works whether
7617 or not error tags are enabled (@option{-gnatw.d}) is to use the
7618 @option{-gnatw} tag string, enclosed in brackets,
7619 as shown in the example below, to treat a class of warnings as errors.
7620
7621 The above use of patterns to match the message applies only to warning
7622 messages generated by the front end. This pragma can also be applied to
7623 warnings provided by the back end and mentioned in @ref{Pragma Warnings}.
7624 By using a single full @option{-Wxxx} switch in the pragma, such warnings
7625 can also be treated as errors.
7626
7627 The pragma can appear either in a global configuration pragma file
7628 (e.g. @file{gnat.adc}), or at the start of a file. Given a global
7629 configuration pragma file containing:
7630
7631 @smallexample @c ada
7632 pragma Warning_As_Error ("[-gnatwj]");
7633 @end smallexample
7634
7635 @noindent
7636 which will treat all obsolescent feature warnings as errors, the
7637 following program compiles as shown (compile options here are
7638 @option{-gnatwa.d -gnatl -gnatj55}).
7639
7640 @smallexample @c ada
7641 1. pragma Warning_As_Error ("*never assigned*");
7642 2. function Warnerr return String is
7643 3. X : Integer;
7644 |
7645 >>> error: variable "X" is never read and
7646 never assigned [-gnatwv] [warning-as-error]
7647
7648 4. Y : Integer;
7649 |
7650 >>> warning: variable "Y" is assigned but
7651 never read [-gnatwu]
7652
7653 5. begin
7654 6. Y := 0;
7655 7. return %ABC%;
7656 |
7657 >>> error: use of "%" is an obsolescent
7658 feature (RM J.2(4)), use """ instead
7659 [-gnatwj] [warning-as-error]
7660
7661 8. end;
7662
7663 8 lines: No errors, 3 warnings (2 treated as errors)
7664 @end smallexample
7665
7666 @noindent
7667 Note that this pragma does not affect the set of warnings issued in
7668 any way, it merely changes the effect of a matching warning if one
7669 is produced as a result of other warnings options. As shown in this
7670 example, if the pragma results in a warning being treated as an error,
7671 the tag is changed from "warning:" to "error:" and the string
7672 "[warning-as-error]" is appended to the end of the message.
7673
7674 @node Pragma Warnings
7675 @unnumberedsec Pragma Warnings
7676 @findex Warnings
7677 @noindent
7678 Syntax:
7679
7680 @smallexample @c ada
7681 pragma Warnings (On | Off [,REASON]);
7682 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
7683 pragma Warnings (static_string_EXPRESSION [,REASON]);
7684 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
7685
7686 REASON ::= Reason => STRING_LITERAL @{& STRING_LITERAL@}
7687 @end smallexample
7688
7689 @noindent
7690 Normally warnings are enabled, with the output being controlled by
7691 the command line switch. Warnings (@code{Off}) turns off generation of
7692 warnings until a Warnings (@code{On}) is encountered or the end of the
7693 current unit. If generation of warnings is turned off using this
7694 pragma, then some or all of the warning messages are suppressed,
7695 regardless of the setting of the command line switches.
7696
7697 The @code{Reason} parameter may optionally appear as the last argument
7698 in any of the forms of this pragma. It is intended purely for the
7699 purposes of documenting the reason for the @code{Warnings} pragma.
7700 The compiler will check that the argument is a static string but
7701 otherwise ignore this argument. Other tools may provide specialized
7702 processing for this string.
7703
7704 The form with a single argument (or two arguments if Reason present),
7705 where the first argument is @code{ON} or @code{OFF}
7706 may be used as a configuration pragma.
7707
7708 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
7709 the specified entity. This suppression is effective from the point where
7710 it occurs till the end of the extended scope of the variable (similar to
7711 the scope of @code{Suppress}). This form cannot be used as a configuration
7712 pragma.
7713
7714 The form with a single static_string_EXPRESSION argument (and possible
7715 reason) provides more precise
7716 control over which warnings are active. The string is a list of letters
7717 specifying which warnings are to be activated and which deactivated. The
7718 code for these letters is the same as the string used in the command
7719 line switch controlling warnings. For a brief summary, use the gnatmake
7720 command with no arguments, which will generate usage information containing
7721 the list of warnings switches supported. For
7722 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
7723 User's Guide}. This form can also be used as a configuration pragma.
7724
7725 @noindent
7726 The warnings controlled by the @option{-gnatw} switch are generated by the
7727 front end of the compiler. The GCC back end can provide additional warnings
7728 and they are controlled by the @option{-W} switch. Such warnings can be
7729 identified by the appearance of a string of the form @code{[-Wxxx]} in the
7730 message which designates the @option{-Wxxx} switch that controls the message.
7731 The form with a single static_string_EXPRESSION argument also works for these
7732 warnings, but the string must be a single full @option{-Wxxx} switch in this
7733 case. The above reference lists a few examples of these additional warnings.
7734
7735 @noindent
7736 The specified warnings will be in effect until the end of the program
7737 or another pragma Warnings is encountered. The effect of the pragma is
7738 cumulative. Initially the set of warnings is the standard default set
7739 as possibly modified by compiler switches. Then each pragma Warning
7740 modifies this set of warnings as specified. This form of the pragma may
7741 also be used as a configuration pragma.
7742
7743 The fourth form, with an @code{On|Off} parameter and a string, is used to
7744 control individual messages, based on their text. The string argument
7745 is a pattern that is used to match against the text of individual
7746 warning messages (not including the initial "warning: " tag).
7747
7748 The pattern may contain asterisks, which match zero or more characters in
7749 the message. For example, you can use
7750 @code{pragma Warnings (Off, "bits of*unused")} to suppress the warning
7751 message @code{warning: 960 bits of "a" unused}. No other regular
7752 expression notations are permitted. All characters other than asterisk in
7753 these three specific cases are treated as literal characters in the match.
7754 The match is case insensitive, for example XYZ matches xyz.
7755
7756 Note that the pattern matches if it occurs anywhere within the warning
7757 message string (it is not necessary to put an asterisk at the start and
7758 the end of the message, since this is implied).
7759
7760 The above use of patterns to match the message applies only to warning
7761 messages generated by the front end. This form of the pragma with a string
7762 argument can also be used to control warnings provided by the back end and
7763 mentioned above. By using a single full @option{-Wxxx} switch in the pragma,
7764 such warnings can be turned on and off.
7765
7766 There are two ways to use the pragma in this form. The OFF form can be used
7767 as a configuration pragma. The effect is to suppress all warnings (if any)
7768 that match the pattern string throughout the compilation (or match the
7769 -W switch in the back end case).
7770
7771 The second usage is to suppress a warning locally, and in this case, two
7772 pragmas must appear in sequence:
7773
7774 @smallexample @c ada
7775 pragma Warnings (Off, Pattern);
7776 @dots{} code where given warning is to be suppressed
7777 pragma Warnings (On, Pattern);
7778 @end smallexample
7779
7780 @noindent
7781 In this usage, the pattern string must match in the Off and On pragmas,
7782 and at least one matching warning must be suppressed.
7783
7784 Note: to write a string that will match any warning, use the string
7785 @code{"***"}. It will not work to use a single asterisk or two asterisks
7786 since this looks like an operator name. This form with three asterisks
7787 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7788 matching @code{pragma Warnings (On, "***")} will be required. This can be
7789 helpful in avoiding forgetting to turn warnings back on.
7790
7791 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7792 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7793 be useful in checking whether obsolete pragmas in existing programs are hiding
7794 real problems.
7795
7796 Note: pragma Warnings does not affect the processing of style messages. See
7797 separate entry for pragma Style_Checks for control of style messages.
7798
7799 @node Pragma Weak_External
7800 @unnumberedsec Pragma Weak_External
7801 @findex Weak_External
7802 @noindent
7803 Syntax:
7804
7805 @smallexample @c ada
7806 pragma Weak_External ([Entity =>] LOCAL_NAME);
7807 @end smallexample
7808
7809 @noindent
7810 @var{LOCAL_NAME} must refer to an object that is declared at the library
7811 level. This pragma specifies that the given entity should be marked as a
7812 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7813 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7814 of a regular symbol, that is to say a symbol that does not have to be
7815 resolved by the linker if used in conjunction with a pragma Import.
7816
7817 When a weak symbol is not resolved by the linker, its address is set to
7818 zero. This is useful in writing interfaces to external modules that may
7819 or may not be linked in the final executable, for example depending on
7820 configuration settings.
7821
7822 If a program references at run time an entity to which this pragma has been
7823 applied, and the corresponding symbol was not resolved at link time, then
7824 the execution of the program is erroneous. It is not erroneous to take the
7825 Address of such an entity, for example to guard potential references,
7826 as shown in the example below.
7827
7828 Some file formats do not support weak symbols so not all target machines
7829 support this pragma.
7830
7831 @smallexample @c ada
7832 -- Example of the use of pragma Weak_External
7833
7834 package External_Module is
7835 key : Integer;
7836 pragma Import (C, key);
7837 pragma Weak_External (key);
7838 function Present return boolean;
7839 end External_Module;
7840
7841 with System; use System;
7842 package body External_Module is
7843 function Present return boolean is
7844 begin
7845 return key'Address /= System.Null_Address;
7846 end Present;
7847 end External_Module;
7848 @end smallexample
7849
7850 @node Pragma Wide_Character_Encoding
7851 @unnumberedsec Pragma Wide_Character_Encoding
7852 @findex Wide_Character_Encoding
7853 @noindent
7854 Syntax:
7855
7856 @smallexample @c ada
7857 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
7858 @end smallexample
7859
7860 @noindent
7861 This pragma specifies the wide character encoding to be used in program
7862 source text appearing subsequently. It is a configuration pragma, but may
7863 also be used at any point that a pragma is allowed, and it is permissible
7864 to have more than one such pragma in a file, allowing multiple encodings
7865 to appear within the same file.
7866
7867 The argument can be an identifier or a character literal. In the identifier
7868 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
7869 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
7870 case it is correspondingly one of the characters @samp{h}, @samp{u},
7871 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
7872
7873 Note that when the pragma is used within a file, it affects only the
7874 encoding within that file, and does not affect withed units, specs,
7875 or subunits.
7876
7877 @node Implementation Defined Aspects
7878 @chapter Implementation Defined Aspects
7879 Ada defines (throughout the Ada 2012 reference manual, summarized
7880 in Annex K) a set of aspects that can be specified for certain entities.
7881 These language defined aspects are implemented in GNAT in Ada 2012 mode
7882 and work as described in the Ada 2012 Reference Manual.
7883
7884 In addition, Ada 2012 allows implementations to define additional aspects
7885 whose meaning is defined by the implementation. GNAT provides
7886 a number of these implementation-defined aspects which can be used
7887 to extend and enhance the functionality of the compiler. This section of
7888 the GNAT reference manual describes these additional aspects.
7889
7890 Note that any program using these aspects may not be portable to
7891 other compilers (although GNAT implements this set of aspects on all
7892 platforms). Therefore if portability to other compilers is an important
7893 consideration, you should minimize the use of these aspects.
7894
7895 Note that for many of these aspects, the effect is essentially similar
7896 to the use of a pragma or attribute specification with the same name
7897 applied to the entity. For example, if we write:
7898
7899 @smallexample @c ada
7900 type R is range 1 .. 100
7901 with Value_Size => 10;
7902 @end smallexample
7903
7904 @noindent
7905 then the effect is the same as:
7906
7907 @smallexample @c ada
7908 type R is range 1 .. 100;
7909 for R'Value_Size use 10;
7910 @end smallexample
7911
7912 @noindent
7913 and if we write:
7914
7915 @smallexample @c ada
7916 type R is new Integer
7917 with Shared => True;
7918 @end smallexample
7919
7920 @noindent
7921 then the effect is the same as:
7922
7923 @smallexample @c ada
7924 type R is new Integer;
7925 pragma Shared (R);
7926 @end smallexample
7927
7928 @noindent
7929 In the documentation below, such cases are simply marked
7930 as being equivalent to the corresponding pragma or attribute definition
7931 clause.
7932
7933 @menu
7934 * Aspect Abstract_State::
7935 * Aspect Async_Readers::
7936 * Aspect Async_Writers::
7937 * Aspect Contract_Cases::
7938 * Aspect Depends::
7939 * Aspect Dimension::
7940 * Aspect Dimension_System::
7941 * Aspect Effective_Reads::
7942 * Aspect Effective_Writes::
7943 * Aspect Favor_Top_Level::
7944 * Aspect Global::
7945 * Aspect Initial_Condition::
7946 * Aspect Initializes::
7947 * Aspect Inline_Always::
7948 * Aspect Invariant::
7949 * Aspect Linker_Section::
7950 * Aspect Lock_Free::
7951 * Aspect Object_Size::
7952 * Aspect Part_Of::
7953 * Aspect Persistent_BSS::
7954 * Aspect Predicate::
7955 * Aspect Pure_Function::
7956 * Aspect Refined_Depends::
7957 * Aspect Refined_Global::
7958 * Aspect Refined_Post::
7959 * Aspect Refined_State::
7960 * Aspect Remote_Access_Type::
7961 * Aspect Scalar_Storage_Order::
7962 * Aspect Shared::
7963 * Aspect Simple_Storage_Pool::
7964 * Aspect Simple_Storage_Pool_Type::
7965 * Aspect SPARK_Mode::
7966 * Aspect Suppress_Debug_Info::
7967 * Aspect Test_Case::
7968 * Aspect Thread_Local_Storage::
7969 * Aspect Universal_Aliasing::
7970 * Aspect Universal_Data::
7971 * Aspect Unmodified::
7972 * Aspect Unreferenced::
7973 * Aspect Unreferenced_Objects::
7974 * Aspect Value_Size::
7975 * Aspect Warnings::
7976 @end menu
7977
7978 @node Aspect Abstract_State
7979 @unnumberedsec Aspect Abstract_State
7980 @findex Abstract_State
7981 @noindent
7982 This aspect is equivalent to pragma @code{Abstract_State}.
7983
7984 @node Aspect Async_Readers
7985 @unnumberedsec Aspect Async_Readers
7986 @findex Async_Readers
7987 @noindent
7988 This aspect is equivalent to pragma @code{Async_Readers}.
7989
7990 @node Aspect Async_Writers
7991 @unnumberedsec Aspect Async_Writers
7992 @findex Async_Writers
7993 @noindent
7994 This aspect is equivalent to pragma @code{Async_Writers}.
7995
7996 @node Aspect Contract_Cases
7997 @unnumberedsec Aspect Contract_Cases
7998 @findex Contract_Cases
7999 @noindent
8000 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
8001 of clauses being enclosed in parentheses so that syntactically it is an
8002 aggregate.
8003
8004 @node Aspect Depends
8005 @unnumberedsec Aspect Depends
8006 @findex Depends
8007 @noindent
8008 This aspect is equivalent to pragma @code{Depends}.
8009
8010 @node Aspect Dimension
8011 @unnumberedsec Aspect Dimension
8012 @findex Dimension
8013 @noindent
8014 The @code{Dimension} aspect is used to specify the dimensions of a given
8015 subtype of a dimensioned numeric type. The aspect also specifies a symbol
8016 used when doing formatted output of dimensioned quantities. The syntax is:
8017
8018 @smallexample @c ada
8019 with Dimension =>
8020 ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
8021
8022 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
8023
8024 DIMENSION_VALUE ::=
8025 RATIONAL
8026 | others => RATIONAL
8027 | DISCRETE_CHOICE_LIST => RATIONAL
8028
8029 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
8030 @end smallexample
8031
8032 @noindent
8033 This aspect can only be applied to a subtype whose parent type has
8034 a @code{Dimension_Systen} aspect. The aspect must specify values for
8035 all dimensions of the system. The rational values are the powers of the
8036 corresponding dimensions that are used by the compiler to verify that
8037 physical (numeric) computations are dimensionally consistent. For example,
8038 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
8039 For further examples of the usage
8040 of this aspect, see package @code{System.Dim.Mks}.
8041 Note that when the dimensioned type is an integer type, then any
8042 dimension value must be an integer literal.
8043
8044 @node Aspect Dimension_System
8045 @unnumberedsec Aspect Dimension_System
8046 @findex Dimension_System
8047 @noindent
8048 The @code{Dimension_System} aspect is used to define a system of
8049 dimensions that will be used in subsequent subtype declarations with
8050 @code{Dimension} aspects that reference this system. The syntax is:
8051
8052 @smallexample @c ada
8053 with Dimension_System => (DIMENSION @{, DIMENSION@});
8054
8055 DIMENSION ::= ([Unit_Name =>] IDENTIFIER,
8056 [Unit_Symbol =>] SYMBOL,
8057 [Dim_Symbol =>] SYMBOL)
8058
8059 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
8060 @end smallexample
8061
8062 @noindent
8063 This aspect is applied to a type, which must be a numeric derived type
8064 (typically a floating-point type), that
8065 will represent values within the dimension system. Each @code{DIMENSION}
8066 corresponds to one particular dimension. A maximum of 7 dimensions may
8067 be specified. @code{Unit_Name} is the name of the dimension (for example
8068 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
8069 of this dimension (for example @code{m} for @code{Meter}).
8070 @code{Dim_Symbol} gives
8071 the identification within the dimension system (typically this is a
8072 single letter, e.g. @code{L} standing for length for unit name @code{Meter}).
8073 The @code{Unit_Symbol} is used in formatted output of dimensioned quantities.
8074 The @code{Dim_Symbol} is used in error messages when numeric operations have
8075 inconsistent dimensions.
8076
8077 GNAT provides the standard definition of the International MKS system in
8078 the run-time package @code{System.Dim.Mks}. You can easily define
8079 similar packages for cgs units or British units, and define conversion factors
8080 between values in different systems. The MKS system is characterized by the
8081 following aspect:
8082
8083 @smallexample @c ada
8084 type Mks_Type is new Long_Long_Float
8085 with
8086 Dimension_System => (
8087 (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
8088 (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
8089 (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
8090 (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
8091 (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Theta"),
8092 (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
8093 (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
8094 @end smallexample
8095
8096 @noindent
8097 See section ``Performing Dimensionality Analysis in GNAT'' in the GNAT Users
8098 Guide for detailed examples of use of the dimension system.
8099
8100 @node Aspect Effective_Reads
8101 @unnumberedsec Aspect Effective_Reads
8102 @findex Effective_Reads
8103 @noindent
8104 This aspect is equivalent to pragma @code{Effective_Reads}.
8105
8106 @node Aspect Effective_Writes
8107 @unnumberedsec Aspect Effective_Writes
8108 @findex Effective_Writes
8109 @noindent
8110 This aspect is equivalent to pragma @code{Effective_Writes}.
8111
8112 @node Aspect Favor_Top_Level
8113 @unnumberedsec Aspect Favor_Top_Level
8114 @findex Favor_Top_Level
8115 @noindent
8116 This aspect is equivalent to pragma @code{Favor_Top_Level}.
8117
8118 @node Aspect Global
8119 @unnumberedsec Aspect Global
8120 @findex Global
8121 @noindent
8122 This aspect is equivalent to pragma @code{Global}.
8123
8124 @node Aspect Initial_Condition
8125 @unnumberedsec Aspect Initial_Condition
8126 @findex Initial_Condition
8127 @noindent
8128 This aspect is equivalent to pragma @code{Initial_Condition}.
8129
8130 @node Aspect Initializes
8131 @unnumberedsec Aspect Initializes
8132 @findex Initializes
8133 @noindent
8134 This aspect is equivalent to pragma @code{Initializes}.
8135
8136 @node Aspect Inline_Always
8137 @unnumberedsec Aspect Inline_Always
8138 @findex Inline_Always
8139 @noindent
8140 This aspect is equivalent to pragma @code{Inline_Always}.
8141
8142 @node Aspect Invariant
8143 @unnumberedsec Aspect Invariant
8144 @findex Invariant
8145 @noindent
8146 This aspect is equivalent to pragma @code{Invariant}. It is a
8147 synonym for the language defined aspect @code{Type_Invariant} except
8148 that it is separately controllable using pragma @code{Assertion_Policy}.
8149
8150 @node Aspect Linker_Section
8151 @unnumberedsec Aspect Linker_Section
8152 @findex Linker_Section
8153 @noindent
8154 This aspect is equivalent to an @code{Linker_Section} pragma.
8155
8156 @node Aspect Lock_Free
8157 @unnumberedsec Aspect Lock_Free
8158 @findex Lock_Free
8159 @noindent
8160 This aspect is equivalent to pragma @code{Lock_Free}.
8161
8162 @node Aspect Object_Size
8163 @unnumberedsec Aspect Object_Size
8164 @findex Object_Size
8165 @noindent
8166 This aspect is equivalent to an @code{Object_Size} attribute definition
8167 clause.
8168
8169 @node Aspect Part_Of
8170 @unnumberedsec Aspect Part_Of
8171 @findex Part_Of
8172 @noindent
8173 This aspect is equivalent to pragma @code{Part_Of}.
8174
8175 @node Aspect Persistent_BSS
8176 @unnumberedsec Aspect Persistent_BSS
8177 @findex Persistent_BSS
8178 @noindent
8179 This aspect is equivalent to pragma @code{Persistent_BSS}.
8180
8181 @node Aspect Predicate
8182 @unnumberedsec Aspect Predicate
8183 @findex Predicate
8184 @noindent
8185 This aspect is equivalent to pragma @code{Predicate}. It is thus
8186 similar to the language defined aspects @code{Dynamic_Predicate}
8187 and @code{Static_Predicate} except that whether the resulting
8188 predicate is static or dynamic is controlled by the form of the
8189 expression. It is also separately controllable using pragma
8190 @code{Assertion_Policy}.
8191
8192 @node Aspect Pure_Function
8193 @unnumberedsec Aspect Pure_Function
8194 @findex Pure_Function
8195 @noindent
8196 This aspect is equivalent to pragma @code{Pure_Function}.
8197
8198 @node Aspect Refined_Depends
8199 @unnumberedsec Aspect Refined_Depends
8200 @findex Refined_Depends
8201 @noindent
8202 This aspect is equivalent to pragma @code{Refined_Depends}.
8203
8204 @node Aspect Refined_Global
8205 @unnumberedsec Aspect Refined_Global
8206 @findex Refined_Global
8207 @noindent
8208 This aspect is equivalent to pragma @code{Refined_Global}.
8209
8210 @node Aspect Refined_Post
8211 @unnumberedsec Aspect Refined_Post
8212 @findex Refined_Post
8213 @noindent
8214 This aspect is equivalent to pragma @code{Refined_Post}.
8215
8216 @node Aspect Refined_State
8217 @unnumberedsec Aspect Refined_State
8218 @findex Refined_State
8219 @noindent
8220 This aspect is equivalent to pragma @code{Refined_State}.
8221
8222 @node Aspect Remote_Access_Type
8223 @unnumberedsec Aspect Remote_Access_Type
8224 @findex Remote_Access_Type
8225 @noindent
8226 This aspect is equivalent to pragma @code{Remote_Access_Type}.
8227
8228 @node Aspect Scalar_Storage_Order
8229 @unnumberedsec Aspect Scalar_Storage_Order
8230 @findex Scalar_Storage_Order
8231 @noindent
8232 This aspect is equivalent to a @code{Scalar_Storage_Order}
8233 attribute definition clause.
8234
8235 @node Aspect Shared
8236 @unnumberedsec Aspect Shared
8237 @findex Shared
8238 @noindent
8239 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
8240 for aspect @code{Atomic}.
8241
8242 @node Aspect Simple_Storage_Pool
8243 @unnumberedsec Aspect Simple_Storage_Pool
8244 @findex Simple_Storage_Pool
8245 @noindent
8246 This aspect is equivalent to a @code{Simple_Storage_Pool}
8247 attribute definition clause.
8248
8249 @node Aspect Simple_Storage_Pool_Type
8250 @unnumberedsec Aspect Simple_Storage_Pool_Type
8251 @findex Simple_Storage_Pool_Type
8252 @noindent
8253 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
8254
8255 @node Aspect SPARK_Mode
8256 @unnumberedsec Aspect SPARK_Mode
8257 @findex SPARK_Mode
8258 @noindent
8259 This aspect is equivalent to pragma @code{SPARK_Mode} and
8260 may be specified for either or both of the specification and body
8261 of a subprogram or package.
8262
8263 @node Aspect Suppress_Debug_Info
8264 @unnumberedsec Aspect Suppress_Debug_Info
8265 @findex Suppress_Debug_Info
8266 @noindent
8267 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
8268
8269 @node Aspect Test_Case
8270 @unnumberedsec Aspect Test_Case
8271 @findex Test_Case
8272 @noindent
8273 This aspect is equivalent to pragma @code{Test_Case}.
8274
8275 @node Aspect Thread_Local_Storage
8276 @unnumberedsec Aspect Thread_Local_Storage
8277 @findex Thread_Local_Storage
8278 @noindent
8279 This aspect is equivalent to pragma @code{Thread_Local_Storage}.
8280
8281 @node Aspect Universal_Aliasing
8282 @unnumberedsec Aspect Universal_Aliasing
8283 @findex Universal_Aliasing
8284 @noindent
8285 This aspect is equivalent to pragma @code{Universal_Aliasing}.
8286
8287 @node Aspect Universal_Data
8288 @unnumberedsec Aspect Universal_Data
8289 @findex Universal_Data
8290 @noindent
8291 This aspect is equivalent to pragma @code{Universal_Data}.
8292
8293 @node Aspect Unmodified
8294 @unnumberedsec Aspect Unmodified
8295 @findex Unmodified
8296 @noindent
8297 This aspect is equivalent to pragma @code{Unmodified}.
8298
8299 @node Aspect Unreferenced
8300 @unnumberedsec Aspect Unreferenced
8301 @findex Unreferenced
8302 @noindent
8303 This aspect is equivalent to pragma @code{Unreferenced}.
8304
8305 @node Aspect Unreferenced_Objects
8306 @unnumberedsec Aspect Unreferenced_Objects
8307 @findex Unreferenced_Objects
8308 @noindent
8309 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
8310
8311 @node Aspect Value_Size
8312 @unnumberedsec Aspect Value_Size
8313 @findex Value_Size
8314 @noindent
8315 This aspect is equivalent to a @code{Value_Size}
8316 attribute definition clause.
8317
8318 @node Aspect Warnings
8319 @unnumberedsec Aspect Warnings
8320 @findex Warnings
8321 @noindent
8322 This aspect is equivalent to the two argument form of pragma @code{Warnings},
8323 where the first argument is @code{ON} or @code{OFF} and the second argument
8324 is the entity.
8325
8326
8327 @node Implementation Defined Attributes
8328 @chapter Implementation Defined Attributes
8329 Ada defines (throughout the Ada reference manual,
8330 summarized in Annex K),
8331 a set of attributes that provide useful additional functionality in all
8332 areas of the language. These language defined attributes are implemented
8333 in GNAT and work as described in the Ada Reference Manual.
8334
8335 In addition, Ada allows implementations to define additional
8336 attributes whose meaning is defined by the implementation. GNAT provides
8337 a number of these implementation-dependent attributes which can be used
8338 to extend and enhance the functionality of the compiler. This section of
8339 the GNAT reference manual describes these additional attributes.
8340
8341 Note that any program using these attributes may not be portable to
8342 other compilers (although GNAT implements this set of attributes on all
8343 platforms). Therefore if portability to other compilers is an important
8344 consideration, you should minimize the use of these attributes.
8345
8346 @menu
8347 * Attribute Abort_Signal::
8348 * Attribute Address_Size::
8349 * Attribute Asm_Input::
8350 * Attribute Asm_Output::
8351 * Attribute AST_Entry::
8352 * Attribute Bit::
8353 * Attribute Bit_Position::
8354 * Attribute Compiler_Version::
8355 * Attribute Code_Address::
8356 * Attribute Default_Bit_Order::
8357 * Attribute Descriptor_Size::
8358 * Attribute Elaborated::
8359 * Attribute Elab_Body::
8360 * Attribute Elab_Spec::
8361 * Attribute Elab_Subp_Body::
8362 * Attribute Emax::
8363 * Attribute Enabled::
8364 * Attribute Enum_Rep::
8365 * Attribute Enum_Val::
8366 * Attribute Epsilon::
8367 * Attribute Fixed_Value::
8368 * Attribute Has_Access_Values::
8369 * Attribute Has_Discriminants::
8370 * Attribute Img::
8371 * Attribute Integer_Value::
8372 * Attribute Invalid_Value::
8373 * Attribute Large::
8374 * Attribute Library_Level::
8375 * Attribute Loop_Entry::
8376 * Attribute Machine_Size::
8377 * Attribute Mantissa::
8378 * Attribute Max_Interrupt_Priority::
8379 * Attribute Max_Priority::
8380 * Attribute Maximum_Alignment::
8381 * Attribute Mechanism_Code::
8382 * Attribute Null_Parameter::
8383 * Attribute Object_Size::
8384 * Attribute Passed_By_Reference::
8385 * Attribute Pool_Address::
8386 * Attribute Range_Length::
8387 * Attribute Ref::
8388 * Attribute Restriction_Set::
8389 * Attribute Result::
8390 * Attribute Safe_Emax::
8391 * Attribute Safe_Large::
8392 * Attribute Scalar_Storage_Order::
8393 * Attribute Simple_Storage_Pool::
8394 * Attribute Small::
8395 * Attribute Storage_Unit::
8396 * Attribute Stub_Type::
8397 * Attribute System_Allocator_Alignment::
8398 * Attribute Target_Name::
8399 * Attribute Tick::
8400 * Attribute To_Address::
8401 * Attribute Type_Class::
8402 * Attribute UET_Address::
8403 * Attribute Unconstrained_Array::
8404 * Attribute Universal_Literal_String::
8405 * Attribute Unrestricted_Access::
8406 * Attribute Update::
8407 * Attribute Valid_Scalars::
8408 * Attribute VADS_Size::
8409 * Attribute Value_Size::
8410 * Attribute Wchar_T_Size::
8411 * Attribute Word_Size::
8412 @end menu
8413
8414 @node Attribute Abort_Signal
8415 @unnumberedsec Attribute Abort_Signal
8416 @findex Abort_Signal
8417 @noindent
8418 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
8419 prefix) provides the entity for the special exception used to signal
8420 task abort or asynchronous transfer of control. Normally this attribute
8421 should only be used in the tasking runtime (it is highly peculiar, and
8422 completely outside the normal semantics of Ada, for a user program to
8423 intercept the abort exception).
8424
8425 @node Attribute Address_Size
8426 @unnumberedsec Attribute Address_Size
8427 @cindex Size of @code{Address}
8428 @findex Address_Size
8429 @noindent
8430 @code{Standard'Address_Size} (@code{Standard} is the only allowed
8431 prefix) is a static constant giving the number of bits in an
8432 @code{Address}. It is the same value as System.Address'Size,
8433 but has the advantage of being static, while a direct
8434 reference to System.Address'Size is non-static because Address
8435 is a private type.
8436
8437 @node Attribute Asm_Input
8438 @unnumberedsec Attribute Asm_Input
8439 @findex Asm_Input
8440 @noindent
8441 The @code{Asm_Input} attribute denotes a function that takes two
8442 parameters. The first is a string, the second is an expression of the
8443 type designated by the prefix. The first (string) argument is required
8444 to be a static expression, and is the constraint for the parameter,
8445 (e.g.@: what kind of register is required). The second argument is the
8446 value to be used as the input argument. The possible values for the
8447 constant are the same as those used in the RTL, and are dependent on
8448 the configuration file used to built the GCC back end.
8449 @ref{Machine Code Insertions}
8450
8451 @node Attribute Asm_Output
8452 @unnumberedsec Attribute Asm_Output
8453 @findex Asm_Output
8454 @noindent
8455 The @code{Asm_Output} attribute denotes a function that takes two
8456 parameters. The first is a string, the second is the name of a variable
8457 of the type designated by the attribute prefix. The first (string)
8458 argument is required to be a static expression and designates the
8459 constraint for the parameter (e.g.@: what kind of register is
8460 required). The second argument is the variable to be updated with the
8461 result. The possible values for constraint are the same as those used in
8462 the RTL, and are dependent on the configuration file used to build the
8463 GCC back end. If there are no output operands, then this argument may
8464 either be omitted, or explicitly given as @code{No_Output_Operands}.
8465 @ref{Machine Code Insertions}
8466
8467 @node Attribute AST_Entry
8468 @unnumberedsec Attribute AST_Entry
8469 @cindex OpenVMS
8470 @findex AST_Entry
8471 @noindent
8472 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
8473 the name of an entry, it yields a value of the predefined type AST_Handler
8474 (declared in the predefined package System, as extended by the use of
8475 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
8476 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
8477 Language Reference Manual}, section 9.12a.
8478
8479 @node Attribute Bit
8480 @unnumberedsec Attribute Bit
8481 @findex Bit
8482 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
8483 offset within the storage unit (byte) that contains the first bit of
8484 storage allocated for the object. The value of this attribute is of the
8485 type @code{Universal_Integer}, and is always a non-negative number not
8486 exceeding the value of @code{System.Storage_Unit}.
8487
8488 For an object that is a variable or a constant allocated in a register,
8489 the value is zero. (The use of this attribute does not force the
8490 allocation of a variable to memory).
8491
8492 For an object that is a formal parameter, this attribute applies
8493 to either the matching actual parameter or to a copy of the
8494 matching actual parameter.
8495
8496 For an access object the value is zero. Note that
8497 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
8498 designated object. Similarly for a record component
8499 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
8500 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
8501 are subject to index checks.
8502
8503 This attribute is designed to be compatible with the DEC Ada 83 definition
8504 and implementation of the @code{Bit} attribute.
8505
8506 @node Attribute Bit_Position
8507 @unnumberedsec Attribute Bit_Position
8508 @findex Bit_Position
8509 @noindent
8510 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
8511 of the fields of the record type, yields the bit
8512 offset within the record contains the first bit of
8513 storage allocated for the object. The value of this attribute is of the
8514 type @code{Universal_Integer}. The value depends only on the field
8515 @var{C} and is independent of the alignment of
8516 the containing record @var{R}.
8517
8518 @node Attribute Compiler_Version
8519 @unnumberedsec Attribute Compiler_Version
8520 @findex Compiler_Version
8521 @noindent
8522 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
8523 prefix) yields a static string identifying the version of the compiler
8524 being used to compile the unit containing the attribute reference. A
8525 typical result would be something like "@value{EDITION} @i{version} (20090221)".
8526
8527 @node Attribute Code_Address
8528 @unnumberedsec Attribute Code_Address
8529 @findex Code_Address
8530 @cindex Subprogram address
8531 @cindex Address of subprogram code
8532 @noindent
8533 The @code{'Address}
8534 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
8535 intended effect seems to be to provide
8536 an address value which can be used to call the subprogram by means of
8537 an address clause as in the following example:
8538
8539 @smallexample @c ada
8540 procedure K is @dots{}
8541
8542 procedure L;
8543 for L'Address use K'Address;
8544 pragma Import (Ada, L);
8545 @end smallexample
8546
8547 @noindent
8548 A call to @code{L} is then expected to result in a call to @code{K}@.
8549 In Ada 83, where there were no access-to-subprogram values, this was
8550 a common work-around for getting the effect of an indirect call.
8551 GNAT implements the above use of @code{Address} and the technique
8552 illustrated by the example code works correctly.
8553
8554 However, for some purposes, it is useful to have the address of the start
8555 of the generated code for the subprogram. On some architectures, this is
8556 not necessarily the same as the @code{Address} value described above.
8557 For example, the @code{Address} value may reference a subprogram
8558 descriptor rather than the subprogram itself.
8559
8560 The @code{'Code_Address} attribute, which can only be applied to
8561 subprogram entities, always returns the address of the start of the
8562 generated code of the specified subprogram, which may or may not be
8563 the same value as is returned by the corresponding @code{'Address}
8564 attribute.
8565
8566 @node Attribute Default_Bit_Order
8567 @unnumberedsec Attribute Default_Bit_Order
8568 @cindex Big endian
8569 @cindex Little endian
8570 @findex Default_Bit_Order
8571 @noindent
8572 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
8573 permissible prefix), provides the value @code{System.Default_Bit_Order}
8574 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
8575 @code{Low_Order_First}). This is used to construct the definition of
8576 @code{Default_Bit_Order} in package @code{System}.
8577
8578 @node Attribute Descriptor_Size
8579 @unnumberedsec Attribute Descriptor_Size
8580 @cindex Descriptor
8581 @cindex Dope vector
8582 @findex Descriptor_Size
8583 @noindent
8584 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
8585 descriptor allocated for a type. The result is non-zero only for unconstrained
8586 array types and the returned value is of type universal integer. In GNAT, an
8587 array descriptor contains bounds information and is located immediately before
8588 the first element of the array.
8589
8590 @smallexample @c ada
8591 type Unconstr_Array is array (Positive range <>) of Boolean;
8592 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
8593 @end smallexample
8594
8595 @noindent
8596 The attribute takes into account any additional padding due to type alignment.
8597 In the example above, the descriptor contains two values of type
8598 @code{Positive} representing the low and high bound. Since @code{Positive} has
8599 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
8600 Positive'Size + 2} or 64 bits.
8601
8602 @node Attribute Elaborated
8603 @unnumberedsec Attribute Elaborated
8604 @findex Elaborated
8605 @noindent
8606 The prefix of the @code{'Elaborated} attribute must be a unit name. The
8607 value is a Boolean which indicates whether or not the given unit has been
8608 elaborated. This attribute is primarily intended for internal use by the
8609 generated code for dynamic elaboration checking, but it can also be used
8610 in user programs. The value will always be True once elaboration of all
8611 units has been completed. An exception is for units which need no
8612 elaboration, the value is always False for such units.
8613
8614 @node Attribute Elab_Body
8615 @unnumberedsec Attribute Elab_Body
8616 @findex Elab_Body
8617 @noindent
8618 This attribute can only be applied to a program unit name. It returns
8619 the entity for the corresponding elaboration procedure for elaborating
8620 the body of the referenced unit. This is used in the main generated
8621 elaboration procedure by the binder and is not normally used in any
8622 other context. However, there may be specialized situations in which it
8623 is useful to be able to call this elaboration procedure from Ada code,
8624 e.g.@: if it is necessary to do selective re-elaboration to fix some
8625 error.
8626
8627 @node Attribute Elab_Spec
8628 @unnumberedsec Attribute Elab_Spec
8629 @findex Elab_Spec
8630 @noindent
8631 This attribute can only be applied to a program unit name. It returns
8632 the entity for the corresponding elaboration procedure for elaborating
8633 the spec of the referenced unit. This is used in the main
8634 generated elaboration procedure by the binder and is not normally used
8635 in any other context. However, there may be specialized situations in
8636 which it is useful to be able to call this elaboration procedure from
8637 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
8638 some error.
8639
8640 @node Attribute Elab_Subp_Body
8641 @unnumberedsec Attribute Elab_Subp_Body
8642 @findex Elab_Subp_Body
8643 @noindent
8644 This attribute can only be applied to a library level subprogram
8645 name and is only allowed in CodePeer mode. It returns the entity
8646 for the corresponding elaboration procedure for elaborating the body
8647 of the referenced subprogram unit. This is used in the main generated
8648 elaboration procedure by the binder in CodePeer mode only and is unrecognized
8649 otherwise.
8650
8651 @node Attribute Emax
8652 @unnumberedsec Attribute Emax
8653 @cindex Ada 83 attributes
8654 @findex Emax
8655 @noindent
8656 The @code{Emax} attribute is provided for compatibility with Ada 83. See
8657 the Ada 83 reference manual for an exact description of the semantics of
8658 this attribute.
8659
8660 @node Attribute Enabled
8661 @unnumberedsec Attribute Enabled
8662 @findex Enabled
8663 @noindent
8664 The @code{Enabled} attribute allows an application program to check at compile
8665 time to see if the designated check is currently enabled. The prefix is a
8666 simple identifier, referencing any predefined check name (other than
8667 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
8668 no argument is given for the attribute, the check is for the general state
8669 of the check, if an argument is given, then it is an entity name, and the
8670 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
8671 given naming the entity (if not, then the argument is ignored).
8672
8673 Note that instantiations inherit the check status at the point of the
8674 instantiation, so a useful idiom is to have a library package that
8675 introduces a check name with @code{pragma Check_Name}, and then contains
8676 generic packages or subprograms which use the @code{Enabled} attribute
8677 to see if the check is enabled. A user of this package can then issue
8678 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
8679 the package or subprogram, controlling whether the check will be present.
8680
8681 @node Attribute Enum_Rep
8682 @unnumberedsec Attribute Enum_Rep
8683 @cindex Representation of enums
8684 @findex Enum_Rep
8685 @noindent
8686 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
8687 function with the following spec:
8688
8689 @smallexample @c ada
8690 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
8691 return @i{Universal_Integer};
8692 @end smallexample
8693
8694 @noindent
8695 It is also allowable to apply @code{Enum_Rep} directly to an object of an
8696 enumeration type or to a non-overloaded enumeration
8697 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
8698 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
8699 enumeration literal or object.
8700
8701 The function returns the representation value for the given enumeration
8702 value. This will be equal to value of the @code{Pos} attribute in the
8703 absence of an enumeration representation clause. This is a static
8704 attribute (i.e.@: the result is static if the argument is static).
8705
8706 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
8707 in which case it simply returns the integer value. The reason for this
8708 is to allow it to be used for @code{(<>)} discrete formal arguments in
8709 a generic unit that can be instantiated with either enumeration types
8710 or integer types. Note that if @code{Enum_Rep} is used on a modular
8711 type whose upper bound exceeds the upper bound of the largest signed
8712 integer type, and the argument is a variable, so that the universal
8713 integer calculation is done at run time, then the call to @code{Enum_Rep}
8714 may raise @code{Constraint_Error}.
8715
8716 @node Attribute Enum_Val
8717 @unnumberedsec Attribute Enum_Val
8718 @cindex Representation of enums
8719 @findex Enum_Val
8720 @noindent
8721 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
8722 function with the following spec:
8723
8724 @smallexample @c ada
8725 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
8726 return @var{S}'Base};
8727 @end smallexample
8728
8729 @noindent
8730 The function returns the enumeration value whose representation matches the
8731 argument, or raises Constraint_Error if no enumeration literal of the type
8732 has the matching value.
8733 This will be equal to value of the @code{Val} attribute in the
8734 absence of an enumeration representation clause. This is a static
8735 attribute (i.e.@: the result is static if the argument is static).
8736
8737 @node Attribute Epsilon
8738 @unnumberedsec Attribute Epsilon
8739 @cindex Ada 83 attributes
8740 @findex Epsilon
8741 @noindent
8742 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
8743 the Ada 83 reference manual for an exact description of the semantics of
8744 this attribute.
8745
8746 @node Attribute Fixed_Value
8747 @unnumberedsec Attribute Fixed_Value
8748 @findex Fixed_Value
8749 @noindent
8750 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
8751 function with the following specification:
8752
8753 @smallexample @c ada
8754 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
8755 return @var{S};
8756 @end smallexample
8757
8758 @noindent
8759 The value returned is the fixed-point value @var{V} such that
8760
8761 @smallexample @c ada
8762 @var{V} = Arg * @var{S}'Small
8763 @end smallexample
8764
8765 @noindent
8766 The effect is thus similar to first converting the argument to the
8767 integer type used to represent @var{S}, and then doing an unchecked
8768 conversion to the fixed-point type. The difference is
8769 that there are full range checks, to ensure that the result is in range.
8770 This attribute is primarily intended for use in implementation of the
8771 input-output functions for fixed-point values.
8772
8773 @node Attribute Has_Access_Values
8774 @unnumberedsec Attribute Has_Access_Values
8775 @cindex Access values, testing for
8776 @findex Has_Access_Values
8777 @noindent
8778 The prefix of the @code{Has_Access_Values} attribute is a type. The result
8779 is a Boolean value which is True if the is an access type, or is a composite
8780 type with a component (at any nesting depth) that is an access type, and is
8781 False otherwise.
8782 The intended use of this attribute is in conjunction with generic
8783 definitions. If the attribute is applied to a generic private type, it
8784 indicates whether or not the corresponding actual type has access values.
8785
8786 @node Attribute Has_Discriminants
8787 @unnumberedsec Attribute Has_Discriminants
8788 @cindex Discriminants, testing for
8789 @findex Has_Discriminants
8790 @noindent
8791 The prefix of the @code{Has_Discriminants} attribute is a type. The result
8792 is a Boolean value which is True if the type has discriminants, and False
8793 otherwise. The intended use of this attribute is in conjunction with generic
8794 definitions. If the attribute is applied to a generic private type, it
8795 indicates whether or not the corresponding actual type has discriminants.
8796
8797 @node Attribute Img
8798 @unnumberedsec Attribute Img
8799 @findex Img
8800 @noindent
8801 The @code{Img} attribute differs from @code{Image} in that it is applied
8802 directly to an object, and yields the same result as
8803 @code{Image} for the subtype of the object. This is convenient for
8804 debugging:
8805
8806 @smallexample @c ada
8807 Put_Line ("X = " & X'Img);
8808 @end smallexample
8809
8810 @noindent
8811 has the same meaning as the more verbose:
8812
8813 @smallexample @c ada
8814 Put_Line ("X = " & @var{T}'Image (X));
8815 @end smallexample
8816
8817 @noindent
8818 where @var{T} is the (sub)type of the object @code{X}.
8819
8820 Note that technically, in analogy to @code{Image},
8821 @code{X'Img} returns a parameterless function
8822 that returns the appropriate string when called. This means that
8823 @code{X'Img} can be renamed as a function-returning-string, or used
8824 in an instantiation as a function parameter.
8825
8826 @node Attribute Integer_Value
8827 @unnumberedsec Attribute Integer_Value
8828 @findex Integer_Value
8829 @noindent
8830 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
8831 function with the following spec:
8832
8833 @smallexample @c ada
8834 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
8835 return @var{S};
8836 @end smallexample
8837
8838 @noindent
8839 The value returned is the integer value @var{V}, such that
8840
8841 @smallexample @c ada
8842 Arg = @var{V} * @var{T}'Small
8843 @end smallexample
8844
8845 @noindent
8846 where @var{T} is the type of @code{Arg}.
8847 The effect is thus similar to first doing an unchecked conversion from
8848 the fixed-point type to its corresponding implementation type, and then
8849 converting the result to the target integer type. The difference is
8850 that there are full range checks, to ensure that the result is in range.
8851 This attribute is primarily intended for use in implementation of the
8852 standard input-output functions for fixed-point values.
8853
8854 @node Attribute Invalid_Value
8855 @unnumberedsec Attribute Invalid_Value
8856 @findex Invalid_Value
8857 @noindent
8858 For every scalar type S, S'Invalid_Value returns an undefined value of the
8859 type. If possible this value is an invalid representation for the type. The
8860 value returned is identical to the value used to initialize an otherwise
8861 uninitialized value of the type if pragma Initialize_Scalars is used,
8862 including the ability to modify the value with the binder -Sxx flag and
8863 relevant environment variables at run time.
8864
8865 @node Attribute Large
8866 @unnumberedsec Attribute Large
8867 @cindex Ada 83 attributes
8868 @findex Large
8869 @noindent
8870 The @code{Large} attribute is provided for compatibility with Ada 83. See
8871 the Ada 83 reference manual for an exact description of the semantics of
8872 this attribute.
8873
8874 @node Attribute Library_Level
8875 @unnumberedsec Attribute Library_Level
8876 @findex Library_Level
8877 @noindent
8878 @noindent
8879 @code{P'Library_Level}, where P is an entity name,
8880 returns a Boolean value which is True if the entity is declared
8881 at the library level, and False otherwise. Note that within a
8882 generic instantition, the name of the generic unit denotes the
8883 instance, which means that this attribute can be used to test
8884 if a generic is instantiated at the library level, as shown
8885 in this example:
8886
8887 @smallexample @c ada
8888 generic
8889 ...
8890 package Gen is
8891 pragma Compile_Time_Error
8892 (not Gen'Library_Level,
8893 "Gen can only be instantiated at library level");
8894 ...
8895 end Gen;
8896 @end smallexample
8897
8898 @node Attribute Loop_Entry
8899 @unnumberedsec Attribute Loop_Entry
8900 @findex Loop_Entry
8901 @noindent
8902 Syntax:
8903
8904 @smallexample @c ada
8905 X'Loop_Entry [(loop_name)]
8906 @end smallexample
8907
8908 @noindent
8909 The @code{Loop_Entry} attribute is used to refer to the value that an
8910 expression had upon entry to a given loop in much the same way that the
8911 @code{Old} attribute in a subprogram postcondition can be used to refer
8912 to the value an expression had upon entry to the subprogram. The
8913 relevant loop is either identified by the given loop name, or it is the
8914 innermost enclosing loop when no loop name is given.
8915
8916 @noindent
8917 A @code{Loop_Entry} attribute can only occur within a
8918 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
8919 @code{Loop_Entry} is to compare the current value of objects with their
8920 initial value at loop entry, in a @code{Loop_Invariant} pragma.
8921
8922 @noindent
8923 The effect of using @code{X'Loop_Entry} is the same as declaring
8924 a constant initialized with the initial value of @code{X} at loop
8925 entry. This copy is not performed if the loop is not entered, or if the
8926 corresponding pragmas are ignored or disabled.
8927
8928 @node Attribute Machine_Size
8929 @unnumberedsec Attribute Machine_Size
8930 @findex Machine_Size
8931 @noindent
8932 This attribute is identical to the @code{Object_Size} attribute. It is
8933 provided for compatibility with the DEC Ada 83 attribute of this name.
8934
8935 @node Attribute Mantissa
8936 @unnumberedsec Attribute Mantissa
8937 @cindex Ada 83 attributes
8938 @findex Mantissa
8939 @noindent
8940 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
8941 the Ada 83 reference manual for an exact description of the semantics of
8942 this attribute.
8943
8944 @node Attribute Max_Interrupt_Priority
8945 @unnumberedsec Attribute Max_Interrupt_Priority
8946 @cindex Interrupt priority, maximum
8947 @findex Max_Interrupt_Priority
8948 @noindent
8949 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
8950 permissible prefix), provides the same value as
8951 @code{System.Max_Interrupt_Priority}.
8952
8953 @node Attribute Max_Priority
8954 @unnumberedsec Attribute Max_Priority
8955 @cindex Priority, maximum
8956 @findex Max_Priority
8957 @noindent
8958 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
8959 prefix) provides the same value as @code{System.Max_Priority}.
8960
8961 @node Attribute Maximum_Alignment
8962 @unnumberedsec Attribute Maximum_Alignment
8963 @cindex Alignment, maximum
8964 @findex Maximum_Alignment
8965 @noindent
8966 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
8967 permissible prefix) provides the maximum useful alignment value for the
8968 target. This is a static value that can be used to specify the alignment
8969 for an object, guaranteeing that it is properly aligned in all
8970 cases.
8971
8972 @node Attribute Mechanism_Code
8973 @unnumberedsec Attribute Mechanism_Code
8974 @cindex Return values, passing mechanism
8975 @cindex Parameters, passing mechanism
8976 @findex Mechanism_Code
8977 @noindent
8978 @code{@var{function}'Mechanism_Code} yields an integer code for the
8979 mechanism used for the result of function, and
8980 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
8981 used for formal parameter number @var{n} (a static integer value with 1
8982 meaning the first parameter) of @var{subprogram}. The code returned is:
8983
8984 @table @asis
8985 @item 1
8986 by copy (value)
8987 @item 2
8988 by reference
8989 @item 3
8990 by descriptor (default descriptor class)
8991 @item 4
8992 by descriptor (UBS: unaligned bit string)
8993 @item 5
8994 by descriptor (UBSB: aligned bit string with arbitrary bounds)
8995 @item 6
8996 by descriptor (UBA: unaligned bit array)
8997 @item 7
8998 by descriptor (S: string, also scalar access type parameter)
8999 @item 8
9000 by descriptor (SB: string with arbitrary bounds)
9001 @item 9
9002 by descriptor (A: contiguous array)
9003 @item 10
9004 by descriptor (NCA: non-contiguous array)
9005 @end table
9006
9007 @noindent
9008 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
9009 @cindex OpenVMS
9010
9011 @node Attribute Null_Parameter
9012 @unnumberedsec Attribute Null_Parameter
9013 @cindex Zero address, passing
9014 @findex Null_Parameter
9015 @noindent
9016 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
9017 type or subtype @var{T} allocated at machine address zero. The attribute
9018 is allowed only as the default expression of a formal parameter, or as
9019 an actual expression of a subprogram call. In either case, the
9020 subprogram must be imported.
9021
9022 The identity of the object is represented by the address zero in the
9023 argument list, independent of the passing mechanism (explicit or
9024 default).
9025
9026 This capability is needed to specify that a zero address should be
9027 passed for a record or other composite object passed by reference.
9028 There is no way of indicating this without the @code{Null_Parameter}
9029 attribute.
9030
9031 @node Attribute Object_Size
9032 @unnumberedsec Attribute Object_Size
9033 @cindex Size, used for objects
9034 @findex Object_Size
9035 @noindent
9036 The size of an object is not necessarily the same as the size of the type
9037 of an object. This is because by default object sizes are increased to be
9038 a multiple of the alignment of the object. For example,
9039 @code{Natural'Size} is
9040 31, but by default objects of type @code{Natural} will have a size of 32 bits.
9041 Similarly, a record containing an integer and a character:
9042
9043 @smallexample @c ada
9044 type Rec is record
9045 I : Integer;
9046 C : Character;
9047 end record;
9048 @end smallexample
9049
9050 @noindent
9051 will have a size of 40 (that is @code{Rec'Size} will be 40). The
9052 alignment will be 4, because of the
9053 integer field, and so the default size of record objects for this type
9054 will be 64 (8 bytes).
9055
9056 If the alignment of the above record is specified to be 1, then the
9057 object size will be 40 (5 bytes). This is true by default, and also
9058 an object size of 40 can be explicitly specified in this case.
9059
9060 A consequence of this capability is that different object sizes can be
9061 given to subtypes that would otherwise be considered in Ada to be
9062 statically matching. But it makes no sense to consider such subtypes
9063 as statically matching. Consequently, in @code{GNAT} we add a rule
9064 to the static matching rules that requires object sizes to match.
9065 Consider this example:
9066
9067 @smallexample @c ada
9068 1. procedure BadAVConvert is
9069 2. type R is new Integer;
9070 3. subtype R1 is R range 1 .. 10;
9071 4. subtype R2 is R range 1 .. 10;
9072 5. for R1'Object_Size use 8;
9073 6. for R2'Object_Size use 16;
9074 7. type R1P is access all R1;
9075 8. type R2P is access all R2;
9076 9. R1PV : R1P := new R1'(4);
9077 10. R2PV : R2P;
9078 11. begin
9079 12. R2PV := R2P (R1PV);
9080 |
9081 >>> target designated subtype not compatible with
9082 type "R1" defined at line 3
9083
9084 13. end;
9085 @end smallexample
9086
9087 @noindent
9088 In the absence of lines 5 and 6,
9089 types @code{R1} and @code{R2} statically match and
9090 hence the conversion on line 12 is legal. But since lines 5 and 6
9091 cause the object sizes to differ, @code{GNAT} considers that types
9092 @code{R1} and @code{R2} are not statically matching, and line 12
9093 generates the diagnostic shown above.
9094
9095 @noindent
9096 Similar additional checks are performed in other contexts requiring
9097 statically matching subtypes.
9098
9099 @node Attribute Passed_By_Reference
9100 @unnumberedsec Attribute Passed_By_Reference
9101 @cindex Parameters, when passed by reference
9102 @findex Passed_By_Reference
9103 @noindent
9104 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
9105 a value of type @code{Boolean} value that is @code{True} if the type is
9106 normally passed by reference and @code{False} if the type is normally
9107 passed by copy in calls. For scalar types, the result is always @code{False}
9108 and is static. For non-scalar types, the result is non-static.
9109
9110 @node Attribute Pool_Address
9111 @unnumberedsec Attribute Pool_Address
9112 @cindex Parameters, when passed by reference
9113 @findex Pool_Address
9114 @noindent
9115 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
9116 of X within its storage pool. This is the same as
9117 @code{@var{X}'Address}, except that for an unconstrained array whose
9118 bounds are allocated just before the first component,
9119 @code{@var{X}'Pool_Address} returns the address of those bounds,
9120 whereas @code{@var{X}'Address} returns the address of the first
9121 component.
9122
9123 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
9124 the object is allocated'', which could be a user-defined storage pool,
9125 the global heap, on the stack, or in a static memory area. For an
9126 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
9127 what is passed to @code{Allocate} and returned from @code{Deallocate}.
9128
9129 @node Attribute Range_Length
9130 @unnumberedsec Attribute Range_Length
9131 @findex Range_Length
9132 @noindent
9133 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
9134 the number of values represented by the subtype (zero for a null
9135 range). The result is static for static subtypes. @code{Range_Length}
9136 applied to the index subtype of a one dimensional array always gives the
9137 same result as @code{Length} applied to the array itself.
9138
9139 @node Attribute Ref
9140 @unnumberedsec Attribute Ref
9141 @findex Ref
9142 @noindent
9143
9144
9145 @node Attribute Restriction_Set
9146 @unnumberedsec Attribute Restriction_Set
9147 @findex Restriction_Set
9148 @cindex Restrictions
9149 @noindent
9150 This attribute allows compile time testing of restrictions that
9151 are currently in effect. It is primarily intended for specializing
9152 code in the run-time based on restrictions that are active (e.g.
9153 don't need to save fpt registers if restriction No_Floating_Point
9154 is known to be in effect), but can be used anywhere.
9155
9156 There are two forms:
9157
9158 @smallexample @c ada
9159 System'Restriction_Set (partition_boolean_restriction_NAME)
9160 System'Restriction_Set (No_Dependence => library_unit_NAME);
9161 @end smallexample
9162
9163 @noindent
9164 In the case of the first form, the only restriction names
9165 allowed are parameterless restrictions that are checked
9166 for consistency at bind time. For a complete list see the
9167 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
9168
9169 The result returned is True if the restriction is known to
9170 be in effect, and False if the restriction is known not to
9171 be in effect. An important guarantee is that the value of
9172 a Restriction_Set attribute is known to be consistent throughout
9173 all the code of a partition.
9174
9175 This is trivially achieved if the entire partition is compiled
9176 with a consistent set of restriction pragmas. However, the
9177 compilation model does not require this. It is possible to
9178 compile one set of units with one set of pragmas, and another
9179 set of units with another set of pragmas. It is even possible
9180 to compile a spec with one set of pragmas, and then WITH the
9181 same spec with a different set of pragmas. Inconsistencies
9182 in the actual use of the restriction are checked at bind time.
9183
9184 In order to achieve the guarantee of consistency for the
9185 Restriction_Set pragma, we consider that a use of the pragma
9186 that yields False is equivalent to a violation of the
9187 restriction.
9188
9189 So for example if you write
9190
9191 @smallexample @c ada
9192 if System'Restriction_Set (No_Floating_Point) then
9193 ...
9194 else
9195 ...
9196 end if;
9197 @end smallexample
9198
9199 @noindent
9200 And the result is False, so that the else branch is executed,
9201 you can assume that this restriction is not set for any unit
9202 in the partition. This is checked by considering this use of
9203 the restriction pragma to be a violation of the restriction
9204 No_Floating_Point. This means that no other unit can attempt
9205 to set this restriction (if some unit does attempt to set it,
9206 the binder will refuse to bind the partition).
9207
9208 Technical note: The restriction name and the unit name are
9209 intepreted entirely syntactically, as in the corresponding
9210 Restrictions pragma, they are not analyzed semantically,
9211 so they do not have a type.
9212
9213 @node Attribute Result
9214 @unnumberedsec Attribute Result
9215 @findex Result
9216 @noindent
9217 @code{@var{function}'Result} can only be used with in a Postcondition pragma
9218 for a function. The prefix must be the name of the corresponding function. This
9219 is used to refer to the result of the function in the postcondition expression.
9220 For a further discussion of the use of this attribute and examples of its use,
9221 see the description of pragma Postcondition.
9222
9223 @node Attribute Safe_Emax
9224 @unnumberedsec Attribute Safe_Emax
9225 @cindex Ada 83 attributes
9226 @findex Safe_Emax
9227 @noindent
9228 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
9229 the Ada 83 reference manual for an exact description of the semantics of
9230 this attribute.
9231
9232 @node Attribute Safe_Large
9233 @unnumberedsec Attribute Safe_Large
9234 @cindex Ada 83 attributes
9235 @findex Safe_Large
9236 @noindent
9237 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
9238 the Ada 83 reference manual for an exact description of the semantics of
9239 this attribute.
9240
9241 @node Attribute Scalar_Storage_Order
9242 @unnumberedsec Attribute Scalar_Storage_Order
9243 @cindex Endianness
9244 @cindex Scalar storage order
9245 @findex Scalar_Storage_Order
9246 @noindent
9247 For every array or record type @var{S}, the representation attribute
9248 @code{Scalar_Storage_Order} denotes the order in which storage elements
9249 that make up scalar components are ordered within S:
9250
9251 @smallexample @c ada
9252 -- Component type definitions
9253
9254 subtype Yr_Type is Natural range 0 .. 127;
9255 subtype Mo_Type is Natural range 1 .. 12;
9256 subtype Da_Type is Natural range 1 .. 31;
9257
9258 -- Record declaration
9259
9260 type Date is record
9261 Years_Since_1980 : Yr_Type;
9262 Month : Mo_Type;
9263 Day_Of_Month : Da_Type;
9264 end record;
9265
9266 -- Record representation clause
9267
9268 for Date use record
9269 Years_Since_1980 at 0 range 0 .. 6;
9270 Month at 0 range 7 .. 10;
9271 Day_Of_Month at 0 range 11 .. 15;
9272 end record;
9273
9274 -- Attribute definition clauses
9275
9276 for Date'Bit_Order use System.High_Order_First;
9277 for Date'Scalar_Storage_Order use System.High_Order_First;
9278 -- If Scalar_Storage_Order is specified, it must be consistent with
9279 -- Bit_Order, so it's best to always define the latter explicitly if
9280 -- the former is used.
9281 @end smallexample
9282
9283 Other properties are
9284 as for standard representation attribute @code{Bit_Order}, as defined by
9285 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
9286
9287 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
9288 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
9289 this means that if a @code{Scalar_Storage_Order} attribute definition
9290 clause is not confirming, then the type's @code{Bit_Order} shall be
9291 specified explicitly and set to the same value.
9292
9293 For a record extension, the derived type shall have the same scalar storage
9294 order as the parent type.
9295
9296 If a component of @var{S} has itself a record or array type, then it shall also
9297 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
9298 if the component is a packed array, or does not start on a byte boundary, then
9299 the scalar storage order specified for S and for the nested component type shall
9300 be identical.
9301
9302 If @var{S} appears as the type of a record or array component, the enclosing
9303 record or array shall also have a @code{Scalar_Storage_Order} attribute
9304 definition clause.
9305
9306 No component of a type that has a @code{Scalar_Storage_Order} attribute
9307 definition may be aliased.
9308
9309 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
9310 with a value equal to @code{System.Default_Bit_Order}) has no effect.
9311
9312 If the opposite storage order is specified, then whenever the value of
9313 a scalar component of an object of type @var{S} is read, the storage
9314 elements of the enclosing machine scalar are first reversed (before
9315 retrieving the component value, possibly applying some shift and mask
9316 operatings on the enclosing machine scalar), and the opposite operation
9317 is done for writes.
9318
9319 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
9320 are relaxed. Instead, the following rules apply:
9321
9322 @itemize @bullet
9323 @item the underlying storage elements are those at positions
9324 @code{(position + first_bit / storage_element_size) ..
9325 (position + (last_bit + storage_element_size - 1) /
9326 storage_element_size)}
9327 @item the sequence of underlying storage elements shall have
9328 a size no greater than the largest machine scalar
9329 @item the enclosing machine scalar is defined as the smallest machine
9330 scalar starting at a position no greater than
9331 @code{position + first_bit / storage_element_size} and covering
9332 storage elements at least up to @code{position + (last_bit +
9333 storage_element_size - 1) / storage_element_size}
9334 @item the position of the component is interpreted relative to that machine
9335 scalar.
9336
9337 @end itemize
9338
9339 @node Attribute Simple_Storage_Pool
9340 @unnumberedsec Attribute Simple_Storage_Pool
9341 @cindex Storage pool, simple
9342 @cindex Simple storage pool
9343 @findex Simple_Storage_Pool
9344 @noindent
9345 For every nonformal, nonderived access-to-object type @var{Acc}, the
9346 representation attribute @code{Simple_Storage_Pool} may be specified
9347 via an attribute_definition_clause (or by specifying the equivalent aspect):
9348
9349 @smallexample @c ada
9350
9351 My_Pool : My_Simple_Storage_Pool_Type;
9352
9353 type Acc is access My_Data_Type;
9354
9355 for Acc'Simple_Storage_Pool use My_Pool;
9356
9357 @end smallexample
9358
9359 @noindent
9360 The name given in an attribute_definition_clause for the
9361 @code{Simple_Storage_Pool} attribute shall denote a variable of
9362 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
9363
9364 The use of this attribute is only allowed for a prefix denoting a type
9365 for which it has been specified. The type of the attribute is the type
9366 of the variable specified as the simple storage pool of the access type,
9367 and the attribute denotes that variable.
9368
9369 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
9370 for the same access type.
9371
9372 If the @code{Simple_Storage_Pool} attribute has been specified for an access
9373 type, then applying the @code{Storage_Pool} attribute to the type is flagged
9374 with a warning and its evaluation raises the exception @code{Program_Error}.
9375
9376 If the Simple_Storage_Pool attribute has been specified for an access
9377 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
9378 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
9379 which is intended to indicate the number of storage elements reserved for
9380 the simple storage pool. If the Storage_Size function has not been defined
9381 for the simple storage pool type, then this attribute returns zero.
9382
9383 If an access type @var{S} has a specified simple storage pool of type
9384 @var{SSP}, then the evaluation of an allocator for that access type calls
9385 the primitive @code{Allocate} procedure for type @var{SSP}, passing
9386 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
9387 semantics of such allocators is the same as those defined for allocators
9388 in section 13.11 of the Ada Reference Manual, with the term
9389 ``simple storage pool'' substituted for ``storage pool''.
9390
9391 If an access type @var{S} has a specified simple storage pool of type
9392 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
9393 for that access type invokes the primitive @code{Deallocate} procedure
9394 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
9395 parameter. The detailed semantics of such unchecked deallocations is the same
9396 as defined in section 13.11.2 of the Ada Reference Manual, except that the
9397 term ``simple storage pool'' is substituted for ``storage pool''.
9398
9399 @node Attribute Small
9400 @unnumberedsec Attribute Small
9401 @cindex Ada 83 attributes
9402 @findex Small
9403 @noindent
9404 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
9405 fixed-point types.
9406 GNAT also allows this attribute to be applied to floating-point types
9407 for compatibility with Ada 83. See
9408 the Ada 83 reference manual for an exact description of the semantics of
9409 this attribute when applied to floating-point types.
9410
9411 @node Attribute Storage_Unit
9412 @unnumberedsec Attribute Storage_Unit
9413 @findex Storage_Unit
9414 @noindent
9415 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
9416 prefix) provides the same value as @code{System.Storage_Unit}.
9417
9418 @node Attribute Stub_Type
9419 @unnumberedsec Attribute Stub_Type
9420 @findex Stub_Type
9421 @noindent
9422 The GNAT implementation of remote access-to-classwide types is
9423 organized as described in AARM section E.4 (20.t): a value of an RACW type
9424 (designating a remote object) is represented as a normal access
9425 value, pointing to a "stub" object which in turn contains the
9426 necessary information to contact the designated remote object. A
9427 call on any dispatching operation of such a stub object does the
9428 remote call, if necessary, using the information in the stub object
9429 to locate the target partition, etc.
9430
9431 For a prefix @code{T} that denotes a remote access-to-classwide type,
9432 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
9433
9434 By construction, the layout of @code{T'Stub_Type} is identical to that of
9435 type @code{RACW_Stub_Type} declared in the internal implementation-defined
9436 unit @code{System.Partition_Interface}. Use of this attribute will create
9437 an implicit dependency on this unit.
9438
9439 @node Attribute System_Allocator_Alignment
9440 @unnumberedsec Attribute System_Allocator_Alignment
9441 @cindex Alignment, allocator
9442 @findex System_Allocator_Alignment
9443 @noindent
9444 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
9445 permissible prefix) provides the observable guaranted to be honored by
9446 the system allocator (malloc). This is a static value that can be used
9447 in user storage pools based on malloc either to reject allocation
9448 with alignment too large or to enable a realignment circuitry if the
9449 alignment request is larger than this value.
9450
9451 @node Attribute Target_Name
9452 @unnumberedsec Attribute Target_Name
9453 @findex Target_Name
9454 @noindent
9455 @code{Standard'Target_Name} (@code{Standard} is the only permissible
9456 prefix) provides a static string value that identifies the target
9457 for the current compilation. For GCC implementations, this is the
9458 standard gcc target name without the terminating slash (for
9459 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
9460
9461 @node Attribute Tick
9462 @unnumberedsec Attribute Tick
9463 @findex Tick
9464 @noindent
9465 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
9466 provides the same value as @code{System.Tick},
9467
9468 @node Attribute To_Address
9469 @unnumberedsec Attribute To_Address
9470 @findex To_Address
9471 @noindent
9472 The @code{System'To_Address}
9473 (@code{System} is the only permissible prefix)
9474 denotes a function identical to
9475 @code{System.Storage_Elements.To_Address} except that
9476 it is a static attribute. This means that if its argument is
9477 a static expression, then the result of the attribute is a
9478 static expression. This means that such an expression can be
9479 used in contexts (e.g.@: preelaborable packages) which require a
9480 static expression and where the function call could not be used
9481 (since the function call is always non-static, even if its
9482 argument is static). The argument must be in the range
9483 -(2**(m-1) .. 2**m-1, where m is the memory size
9484 (typically 32 or 64). Negative values are intepreted in a
9485 modular manner (e.g. -1 means the same as 16#FFFF_FFFF# on
9486 a 32 bits machine).
9487
9488 @node Attribute Type_Class
9489 @unnumberedsec Attribute Type_Class
9490 @findex Type_Class
9491 @noindent
9492 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
9493 the value of the type class for the full type of @var{type}. If
9494 @var{type} is a generic formal type, the value is the value for the
9495 corresponding actual subtype. The value of this attribute is of type
9496 @code{System.Aux_DEC.Type_Class}, which has the following definition:
9497
9498 @smallexample @c ada
9499 type Type_Class is
9500 (Type_Class_Enumeration,
9501 Type_Class_Integer,
9502 Type_Class_Fixed_Point,
9503 Type_Class_Floating_Point,
9504 Type_Class_Array,
9505 Type_Class_Record,
9506 Type_Class_Access,
9507 Type_Class_Task,
9508 Type_Class_Address);
9509 @end smallexample
9510
9511 @noindent
9512 Protected types yield the value @code{Type_Class_Task}, which thus
9513 applies to all concurrent types. This attribute is designed to
9514 be compatible with the DEC Ada 83 attribute of the same name.
9515
9516 @node Attribute UET_Address
9517 @unnumberedsec Attribute UET_Address
9518 @findex UET_Address
9519 @noindent
9520 The @code{UET_Address} attribute can only be used for a prefix which
9521 denotes a library package. It yields the address of the unit exception
9522 table when zero cost exception handling is used. This attribute is
9523 intended only for use within the GNAT implementation. See the unit
9524 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
9525 for details on how this attribute is used in the implementation.
9526
9527 @node Attribute Unconstrained_Array
9528 @unnumberedsec Attribute Unconstrained_Array
9529 @findex Unconstrained_Array
9530 @noindent
9531 The @code{Unconstrained_Array} attribute can be used with a prefix that
9532 denotes any type or subtype. It is a static attribute that yields
9533 @code{True} if the prefix designates an unconstrained array,
9534 and @code{False} otherwise. In a generic instance, the result is
9535 still static, and yields the result of applying this test to the
9536 generic actual.
9537
9538 @node Attribute Universal_Literal_String
9539 @unnumberedsec Attribute Universal_Literal_String
9540 @cindex Named numbers, representation of
9541 @findex Universal_Literal_String
9542 @noindent
9543 The prefix of @code{Universal_Literal_String} must be a named
9544 number. The static result is the string consisting of the characters of
9545 the number as defined in the original source. This allows the user
9546 program to access the actual text of named numbers without intermediate
9547 conversions and without the need to enclose the strings in quotes (which
9548 would preclude their use as numbers).
9549
9550 For example, the following program prints the first 50 digits of pi:
9551
9552 @smallexample @c ada
9553 with Text_IO; use Text_IO;
9554 with Ada.Numerics;
9555 procedure Pi is
9556 begin
9557 Put (Ada.Numerics.Pi'Universal_Literal_String);
9558 end;
9559 @end smallexample
9560
9561 @node Attribute Unrestricted_Access
9562 @unnumberedsec Attribute Unrestricted_Access
9563 @cindex @code{Access}, unrestricted
9564 @findex Unrestricted_Access
9565 @noindent
9566 The @code{Unrestricted_Access} attribute is similar to @code{Access}
9567 except that all accessibility and aliased view checks are omitted. This
9568 is a user-beware attribute. It is similar to
9569 @code{Address}, for which it is a desirable replacement where the value
9570 desired is an access type. In other words, its effect is similar to
9571 first applying the @code{Address} attribute and then doing an unchecked
9572 conversion to a desired access type. In GNAT, but not necessarily in
9573 other implementations, the use of static chains for inner level
9574 subprograms means that @code{Unrestricted_Access} applied to a
9575 subprogram yields a value that can be called as long as the subprogram
9576 is in scope (normal Ada accessibility rules restrict this usage).
9577
9578 It is possible to use @code{Unrestricted_Access} for any type, but care
9579 must be exercised if it is used to create pointers to unconstrained array
9580 objects. In this case, the resulting pointer has the same scope as the
9581 context of the attribute, and may not be returned to some enclosing
9582 scope. For instance, a function cannot use @code{Unrestricted_Access}
9583 to create a unconstrained pointer and then return that value to the
9584 caller. In addition, it is only valid to create pointers to unconstrained
9585 arrays using this attribute if the pointer has the normal default ``fat''
9586 representation where a pointer has two components, one points to the array
9587 and one points to the bounds. If a size clause is used to force ``thin''
9588 representation for a pointer to unconstrained where there is only space for
9589 a single pointer, then the resulting pointer is not usable.
9590
9591 In the simple case where a direct use of Unrestricted_Access attempts
9592 to make a thin pointer for a non-aliased object, the compiler will
9593 reject the use as illegal, as shown in the following example:
9594
9595 @smallexample @c ada
9596 with System; use System;
9597 procedure SliceUA2 is
9598 type A is access all String;
9599 for A'Size use Standard'Address_Size;
9600
9601 procedure P (Arg : A) is
9602 begin
9603 null;
9604 end P;
9605
9606 X : String := "hello world!";
9607 X2 : aliased String := "hello world!";
9608
9609 AV : A := X'Unrestricted_Access; -- ERROR
9610 |
9611 >>> illegal use of Unrestricted_Access attribute
9612 >>> attempt to generate thin pointer to unaliased object
9613
9614 begin
9615 P (X'Unrestricted_Access); -- ERROR
9616 |
9617 >>> illegal use of Unrestricted_Access attribute
9618 >>> attempt to generate thin pointer to unaliased object
9619
9620 P (X(7 .. 12)'Unrestricted_Access); -- ERROR
9621 |
9622 >>> illegal use of Unrestricted_Access attribute
9623 >>> attempt to generate thin pointer to unaliased object
9624
9625 P (X2'Unrestricted_Access); -- OK
9626 end;
9627 @end smallexample
9628
9629 @noindent
9630 but other cases cannot be detected by the compiler, and are
9631 considered to be erroneous. Consider the following example:
9632
9633 @smallexample @c ada
9634 with System; use System;
9635 with System; use System;
9636 procedure SliceUA is
9637 type AF is access all String;
9638
9639 type A is access all String;
9640 for A'Size use Standard'Address_Size;
9641
9642 procedure P (Arg : A) is
9643 begin
9644 if Arg'Length /= 6 then
9645 raise Program_Error;
9646 end if;
9647 end P;
9648
9649 X : String := "hello world!";
9650 Y : AF := X (7 .. 12)'Unrestricted_Access;
9651
9652 begin
9653 P (A (Y));
9654 end;
9655 @end smallexample
9656
9657 @noindent
9658 A normal unconstrained array value
9659 or a constrained array object marked as aliased has the bounds in memory
9660 just before the array, so a thin pointer can retrieve both the data and
9661 the bounds. But in this case, the non-aliased object @code{X} does not have the
9662 bounds before the string. If the size clause for type @code{A}
9663 were not present, then the pointer
9664 would be a fat pointer, where one component is a pointer to the bounds,
9665 and all would be well. But with the size clause present, the conversion from
9666 fat pointer to thin pointer in the call looses the bounds, and so this
9667 program raises a @code{Program_Error} exception if executed.
9668
9669 In general, it is advisable to completely
9670 avoid mixing the use of thin pointers and the use of
9671 @code{Unrestricted_Access} where the designated type is an
9672 unconstrained array. The use of thin pointers should be restricted to
9673 cases of porting legacy code which implicitly assumes the size of pointers,
9674 and such code should not in any case be using this attribute.
9675
9676 Another erroroneous situation arises if the attribute is
9677 applied to a constant. The resulting pointer can be used to access the
9678 constant, but the effect of trying to modify a constant in this manner
9679 is not well-defined. Consider this example:
9680
9681 @smallexample @c ada
9682 P : constant Integer := 4;
9683 type R is access all Integer;
9684 RV : R := P'Unrestricted_Access;
9685 ..
9686 RV.all := 3;
9687 @end smallexample
9688
9689 @noindent
9690 Here we attempt to modify the constant P from 4 to 3, but the compiler may
9691 or may not notice this attempt, and subsequent references to P may yield
9692 either the value 3 or the value 4 or the assignment may blow up if the
9693 compiler decides to put P in read-only memory. One particular case where
9694 @code{Unrestricted_Access} can be used in this way is to modify the
9695 value of an @code{IN} parameter:
9696
9697 @smallexample @c ada
9698 procedure K (S : in String) is
9699 type R is access all Character;
9700 RV : R := S (3)'Unrestricted_Access;
9701 begin
9702 RV.all := 'a';
9703 end;
9704 @end smallexample
9705
9706 @noindent
9707 In general this is a risky approach. It may appear to "work" but such uses of
9708 @code{Unrestricted_Access} are potentially non-portable, even from one version
9709 of @code{GNAT} to another, so are best avoided if possible.
9710
9711 @node Attribute Update
9712 @unnumberedsec Attribute Update
9713 @findex Update
9714 @noindent
9715 The @code{Update} attribute creates a copy of an array or record value
9716 with one or more modified components. The syntax is:
9717
9718 @smallexample @c ada
9719 PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
9720 PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION @{, ARRAY_COMPONENT_ASSOCIATION @} )
9721 PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
9722 @{, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION @} )
9723
9724 MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
9725 INDEX_EXPRESSION_LIST_LIST ::= INDEX_EXPRESSION_LIST @{| INDEX_EXPRESSION_LIST @}
9726 INDEX_EXPRESSION_LIST ::= ( EXPRESSION @{, EXPRESSION @} )
9727 @end smallexample
9728
9729 @noindent
9730 where @code{PREFIX} is the name of an array or record object, and
9731 the association list in parentheses does not contain an @code{others}
9732 choice. The effect is to yield a copy of the array or record value which
9733 is unchanged apart from the components mentioned in the association list, which
9734 are changed to the indicated value. The original value of the array or
9735 record value is not affected. For example:
9736
9737 @smallexample @c ada
9738 type Arr is Array (1 .. 5) of Integer;
9739 ...
9740 Avar1 : Arr := (1,2,3,4,5);
9741 Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
9742 @end smallexample
9743
9744 @noindent
9745 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
9746 begin unmodified. Similarly:
9747
9748 @smallexample @c ada
9749 type Rec is A, B, C : Integer;
9750 ...
9751 Rvar1 : Rec := (A => 1, B => 2, C => 3);
9752 Rvar2 : Rec := Rvar1'Update (B => 20);
9753 @end smallexample
9754
9755 @noindent
9756 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
9757 with @code{Rvar1} being unmodifed.
9758 Note that the value of the attribute reference is computed
9759 completely before it is used. This means that if you write:
9760
9761 @smallexample @c ada
9762 Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
9763 @end smallexample
9764
9765 @noindent
9766 then the value of @code{Avar1} is not modified if @code{Function_Call}
9767 raises an exception, unlike the effect of a series of direct assignments
9768 to elements of @code{Avar1}. In general this requires that
9769 two extra complete copies of the object are required, which should be
9770 kept in mind when considering efficiency.
9771
9772 The @code{Update} attribute cannot be applied to prefixes of a limited
9773 type, and cannot reference discriminants in the case of a record type.
9774 The accessibility level of an Update attribute result object is defined
9775 as for an aggregate.
9776
9777 In the record case, no component can be mentioned more than once. In
9778 the array case, two overlapping ranges can appear in the association list,
9779 in which case the modifications are processed left to right.
9780
9781 Multi-dimensional arrays can be modified, as shown by this example:
9782
9783 @smallexample @c ada
9784 A : array (1 .. 10, 1 .. 10) of Integer;
9785 ..
9786 A := A'Update ((1, 2) => 20, (3, 4) => 30);
9787 @end smallexample
9788
9789 @noindent
9790 which changes element (1,2) to 20 and (3,4) to 30.
9791
9792 @node Attribute Valid_Scalars
9793 @unnumberedsec Attribute Valid_Scalars
9794 @findex Valid_Scalars
9795 @noindent
9796 The @code{'Valid_Scalars} attribute is intended to make it easier to
9797 check the validity of scalar subcomponents of composite objects. It
9798 is defined for any prefix @code{X} that denotes an object.
9799 The value of this attribute is of the predefined type Boolean.
9800 @code{X'Valid_Scalars} yields True if and only if evaluation of
9801 @code{P'Valid} yields True for every scalar part P of X or if X has
9802 no scalar parts. It is not specified in what order the scalar parts
9803 are checked, nor whether any more are checked after any one of them
9804 is determined to be invalid. If the prefix @code{X} is of a class-wide
9805 type @code{T'Class} (where @code{T} is the associated specific type),
9806 or if the prefix @code{X} is of a specific tagged type @code{T}, then
9807 only the scalar parts of components of @code{T} are traversed; in other
9808 words, components of extensions of @code{T} are not traversed even if
9809 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
9810 be determined at compile time that the prefix of the attribute has no
9811 scalar parts (e.g., if the prefix is of an access type, an interface type,
9812 an undiscriminated task type, or an undiscriminated protected type).
9813
9814 @node Attribute VADS_Size
9815 @unnumberedsec Attribute VADS_Size
9816 @cindex @code{Size}, VADS compatibility
9817 @findex VADS_Size
9818 @noindent
9819 The @code{'VADS_Size} attribute is intended to make it easier to port
9820 legacy code which relies on the semantics of @code{'Size} as implemented
9821 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
9822 same semantic interpretation. In particular, @code{'VADS_Size} applied
9823 to a predefined or other primitive type with no Size clause yields the
9824 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
9825 typical machines). In addition @code{'VADS_Size} applied to an object
9826 gives the result that would be obtained by applying the attribute to
9827 the corresponding type.
9828
9829 @node Attribute Value_Size
9830 @unnumberedsec Attribute Value_Size
9831 @cindex @code{Size}, setting for not-first subtype
9832 @findex Value_Size
9833 @code{@var{type}'Value_Size} is the number of bits required to represent
9834 a value of the given subtype. It is the same as @code{@var{type}'Size},
9835 but, unlike @code{Size}, may be set for non-first subtypes.
9836
9837 @node Attribute Wchar_T_Size
9838 @unnumberedsec Attribute Wchar_T_Size
9839 @findex Wchar_T_Size
9840 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
9841 prefix) provides the size in bits of the C @code{wchar_t} type
9842 primarily for constructing the definition of this type in
9843 package @code{Interfaces.C}.
9844
9845 @node Attribute Word_Size
9846 @unnumberedsec Attribute Word_Size
9847 @findex Word_Size
9848 @code{Standard'Word_Size} (@code{Standard} is the only permissible
9849 prefix) provides the value @code{System.Word_Size}.
9850
9851 @node Standard and Implementation Defined Restrictions
9852 @chapter Standard and Implementation Defined Restrictions
9853
9854 @noindent
9855 All RM defined Restriction identifiers are implemented:
9856
9857 @itemize @bullet
9858 @item language-defined restrictions (see 13.12.1)
9859 @item tasking restrictions (see D.7)
9860 @item high integrity restrictions (see H.4)
9861 @end itemize
9862
9863 @noindent
9864 GNAT implements additional restriction identifiers. All restrictions, whether
9865 language defined or GNAT-specific, are listed in the following.
9866
9867 @menu
9868 * Partition-Wide Restrictions::
9869 * Program Unit Level Restrictions::
9870 @end menu
9871
9872 @node Partition-Wide Restrictions
9873 @section Partition-Wide Restrictions
9874
9875 There are two separate lists of restriction identifiers. The first
9876 set requires consistency throughout a partition (in other words, if the
9877 restriction identifier is used for any compilation unit in the partition,
9878 then all compilation units in the partition must obey the restriction).
9879
9880 @menu
9881 * Immediate_Reclamation::
9882 * Max_Asynchronous_Select_Nesting::
9883 * Max_Entry_Queue_Length::
9884 * Max_Protected_Entries::
9885 * Max_Select_Alternatives::
9886 * Max_Storage_At_Blocking::
9887 * Max_Task_Entries::
9888 * Max_Tasks::
9889 * No_Abort_Statements::
9890 * No_Access_Parameter_Allocators::
9891 * No_Access_Subprograms::
9892 * No_Allocators::
9893 * No_Anonymous_Allocators::
9894 * No_Calendar::
9895 * No_Coextensions::
9896 * No_Default_Initialization::
9897 * No_Delay::
9898 * No_Dependence::
9899 * No_Direct_Boolean_Operators::
9900 * No_Dispatch::
9901 * No_Dispatching_Calls::
9902 * No_Dynamic_Attachment::
9903 * No_Dynamic_Priorities::
9904 * No_Entry_Calls_In_Elaboration_Code::
9905 * No_Enumeration_Maps::
9906 * No_Exception_Handlers::
9907 * No_Exception_Propagation::
9908 * No_Exception_Registration::
9909 * No_Exceptions::
9910 * No_Finalization::
9911 * No_Fixed_Point::
9912 * No_Floating_Point::
9913 * No_Implicit_Conditionals::
9914 * No_Implicit_Dynamic_Code::
9915 * No_Implicit_Heap_Allocations::
9916 * No_Implicit_Loops::
9917 * No_Initialize_Scalars::
9918 * No_IO::
9919 * No_Local_Allocators::
9920 * No_Local_Protected_Objects::
9921 * No_Local_Timing_Events::
9922 * No_Long_Long_Integers::
9923 * No_Nested_Finalization::
9924 * No_Protected_Type_Allocators::
9925 * No_Protected_Types::
9926 * No_Recursion::
9927 * No_Reentrancy::
9928 * No_Relative_Delay::
9929 * No_Requeue_Statements::
9930 * No_Secondary_Stack::
9931 * No_Select_Statements::
9932 * No_Specific_Termination_Handlers::
9933 * No_Specification_of_Aspect::
9934 * No_Standard_Allocators_After_Elaboration::
9935 * No_Standard_Storage_Pools::
9936 * No_Stream_Optimizations::
9937 * No_Streams::
9938 * No_Task_Allocators::
9939 * No_Task_Attributes_Package::
9940 * No_Task_Hierarchy::
9941 * No_Task_Termination::
9942 * No_Tasking::
9943 * No_Terminate_Alternatives::
9944 * No_Unchecked_Access::
9945 * Simple_Barriers::
9946 * Static_Priorities::
9947 * Static_Storage_Size::
9948 @end menu
9949
9950 @node Immediate_Reclamation
9951 @unnumberedsubsec Immediate_Reclamation
9952 @findex Immediate_Reclamation
9953 [RM H.4] This restriction ensures that, except for storage occupied by
9954 objects created by allocators and not deallocated via unchecked
9955 deallocation, any storage reserved at run time for an object is
9956 immediately reclaimed when the object no longer exists.
9957
9958 @node Max_Asynchronous_Select_Nesting
9959 @unnumberedsubsec Max_Asynchronous_Select_Nesting
9960 @findex Max_Asynchronous_Select_Nesting
9961 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
9962 selects. Violations of this restriction with a value of zero are
9963 detected at compile time. Violations of this restriction with values
9964 other than zero cause Storage_Error to be raised.
9965
9966 @node Max_Entry_Queue_Length
9967 @unnumberedsubsec Max_Entry_Queue_Length
9968 @findex Max_Entry_Queue_Length
9969 [RM D.7] This restriction is a declaration that any protected entry compiled in
9970 the scope of the restriction has at most the specified number of
9971 tasks waiting on the entry at any one time, and so no queue is required.
9972 Note that this restriction is checked at run time. Violation of this
9973 restriction results in the raising of Program_Error exception at the point of
9974 the call.
9975
9976 @findex Max_Entry_Queue_Depth
9977 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
9978 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
9979 compatibility purposes (and a warning will be generated for its use if
9980 warnings on obsolescent features are activated).
9981
9982 @node Max_Protected_Entries
9983 @unnumberedsubsec Max_Protected_Entries
9984 @findex Max_Protected_Entries
9985 [RM D.7] Specifies the maximum number of entries per protected type. The
9986 bounds of every entry family of a protected unit shall be static, or shall be
9987 defined by a discriminant of a subtype whose corresponding bound is static.
9988
9989 @node Max_Select_Alternatives
9990 @unnumberedsubsec Max_Select_Alternatives
9991 @findex Max_Select_Alternatives
9992 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
9993
9994 @node Max_Storage_At_Blocking
9995 @unnumberedsubsec Max_Storage_At_Blocking
9996 @findex Max_Storage_At_Blocking
9997 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
9998 Storage_Size that can be retained by a blocked task. A violation of this
9999 restriction causes Storage_Error to be raised.
10000
10001 @node Max_Task_Entries
10002 @unnumberedsubsec Max_Task_Entries
10003 @findex Max_Task_Entries
10004 [RM D.7] Specifies the maximum number of entries
10005 per task. The bounds of every entry family
10006 of a task unit shall be static, or shall be
10007 defined by a discriminant of a subtype whose
10008 corresponding bound is static.
10009
10010 @node Max_Tasks
10011 @unnumberedsubsec Max_Tasks
10012 @findex Max_Tasks
10013 [RM D.7] Specifies the maximum number of task that may be created, not
10014 counting the creation of the environment task. Violations of this
10015 restriction with a value of zero are detected at compile
10016 time. Violations of this restriction with values other than zero cause
10017 Storage_Error to be raised.
10018
10019 @node No_Abort_Statements
10020 @unnumberedsubsec No_Abort_Statements
10021 @findex No_Abort_Statements
10022 [RM D.7] There are no abort_statements, and there are
10023 no calls to Task_Identification.Abort_Task.
10024
10025 @node No_Access_Parameter_Allocators
10026 @unnumberedsubsec No_Access_Parameter_Allocators
10027 @findex No_Access_Parameter_Allocators
10028 [RM H.4] This restriction ensures at compile time that there are no
10029 occurrences of an allocator as the actual parameter to an access
10030 parameter.
10031
10032 @node No_Access_Subprograms
10033 @unnumberedsubsec No_Access_Subprograms
10034 @findex No_Access_Subprograms
10035 [RM H.4] This restriction ensures at compile time that there are no
10036 declarations of access-to-subprogram types.
10037
10038 @node No_Allocators
10039 @unnumberedsubsec No_Allocators
10040 @findex No_Allocators
10041 [RM H.4] This restriction ensures at compile time that there are no
10042 occurrences of an allocator.
10043
10044 @node No_Anonymous_Allocators
10045 @unnumberedsubsec No_Anonymous_Allocators
10046 @findex No_Anonymous_Allocators
10047 [RM H.4] This restriction ensures at compile time that there are no
10048 occurrences of an allocator of anonymous access type.
10049
10050 @node No_Calendar
10051 @unnumberedsubsec No_Calendar
10052 @findex No_Calendar
10053 [GNAT] This restriction ensures at compile time that there is no implicit or
10054 explicit dependence on the package @code{Ada.Calendar}.
10055
10056 @node No_Coextensions
10057 @unnumberedsubsec No_Coextensions
10058 @findex No_Coextensions
10059 [RM H.4] This restriction ensures at compile time that there are no
10060 coextensions. See 3.10.2.
10061
10062 @node No_Default_Initialization
10063 @unnumberedsubsec No_Default_Initialization
10064 @findex No_Default_Initialization
10065
10066 [GNAT] This restriction prohibits any instance of default initialization
10067 of variables. The binder implements a consistency rule which prevents
10068 any unit compiled without the restriction from with'ing a unit with the
10069 restriction (this allows the generation of initialization procedures to
10070 be skipped, since you can be sure that no call is ever generated to an
10071 initialization procedure in a unit with the restriction active). If used
10072 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
10073 is to prohibit all cases of variables declared without a specific
10074 initializer (including the case of OUT scalar parameters).
10075
10076 @node No_Delay
10077 @unnumberedsubsec No_Delay
10078 @findex No_Delay
10079 [RM H.4] This restriction ensures at compile time that there are no
10080 delay statements and no dependences on package Calendar.
10081
10082 @node No_Dependence
10083 @unnumberedsubsec No_Dependence
10084 @findex No_Dependence
10085 [RM 13.12.1] This restriction checks at compile time that there are no
10086 dependence on a library unit.
10087
10088 @node No_Direct_Boolean_Operators
10089 @unnumberedsubsec No_Direct_Boolean_Operators
10090 @findex No_Direct_Boolean_Operators
10091 [GNAT] This restriction ensures that no logical operators (and/or/xor)
10092 are used on operands of type Boolean (or any type derived from Boolean).
10093 This is intended for use in safety critical programs where the certification
10094 protocol requires the use of short-circuit (and then, or else) forms for all
10095 composite boolean operations.
10096
10097 @node No_Dispatch
10098 @unnumberedsubsec No_Dispatch
10099 @findex No_Dispatch
10100 [RM H.4] This restriction ensures at compile time that there are no
10101 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
10102
10103 @node No_Dispatching_Calls
10104 @unnumberedsubsec No_Dispatching_Calls
10105 @findex No_Dispatching_Calls
10106 [GNAT] This restriction ensures at compile time that the code generated by the
10107 compiler involves no dispatching calls. The use of this restriction allows the
10108 safe use of record extensions, classwide membership tests and other classwide
10109 features not involving implicit dispatching. This restriction ensures that
10110 the code contains no indirect calls through a dispatching mechanism. Note that
10111 this includes internally-generated calls created by the compiler, for example
10112 in the implementation of class-wide objects assignments. The
10113 membership test is allowed in the presence of this restriction, because its
10114 implementation requires no dispatching.
10115 This restriction is comparable to the official Ada restriction
10116 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
10117 all classwide constructs that do not imply dispatching.
10118 The following example indicates constructs that violate this restriction.
10119
10120 @smallexample
10121 package Pkg is
10122 type T is tagged record
10123 Data : Natural;
10124 end record;
10125 procedure P (X : T);
10126
10127 type DT is new T with record
10128 More_Data : Natural;
10129 end record;
10130 procedure Q (X : DT);
10131 end Pkg;
10132
10133 with Pkg; use Pkg;
10134 procedure Example is
10135 procedure Test (O : T'Class) is
10136 N : Natural := O'Size;-- Error: Dispatching call
10137 C : T'Class := O; -- Error: implicit Dispatching Call
10138 begin
10139 if O in DT'Class then -- OK : Membership test
10140 Q (DT (O)); -- OK : Type conversion plus direct call
10141 else
10142 P (O); -- Error: Dispatching call
10143 end if;
10144 end Test;
10145
10146 Obj : DT;
10147 begin
10148 P (Obj); -- OK : Direct call
10149 P (T (Obj)); -- OK : Type conversion plus direct call
10150 P (T'Class (Obj)); -- Error: Dispatching call
10151
10152 Test (Obj); -- OK : Type conversion
10153
10154 if Obj in T'Class then -- OK : Membership test
10155 null;
10156 end if;
10157 end Example;
10158 @end smallexample
10159
10160 @node No_Dynamic_Attachment
10161 @unnumberedsubsec No_Dynamic_Attachment
10162 @findex No_Dynamic_Attachment
10163 [RM D.7] This restriction ensures that there is no call to any of the
10164 operations defined in package Ada.Interrupts
10165 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
10166 Detach_Handler, and Reference).
10167
10168 @findex No_Dynamic_Interrupts
10169 The restriction @code{No_Dynamic_Interrupts} is recognized as a
10170 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
10171 compatibility purposes (and a warning will be generated for its use if
10172 warnings on obsolescent features are activated).
10173
10174 @node No_Dynamic_Priorities
10175 @unnumberedsubsec No_Dynamic_Priorities
10176 @findex No_Dynamic_Priorities
10177 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
10178
10179 @node No_Entry_Calls_In_Elaboration_Code
10180 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
10181 @findex No_Entry_Calls_In_Elaboration_Code
10182 [GNAT] This restriction ensures at compile time that no task or protected entry
10183 calls are made during elaboration code. As a result of the use of this
10184 restriction, the compiler can assume that no code past an accept statement
10185 in a task can be executed at elaboration time.
10186
10187 @node No_Enumeration_Maps
10188 @unnumberedsubsec No_Enumeration_Maps
10189 @findex No_Enumeration_Maps
10190 [GNAT] This restriction ensures at compile time that no operations requiring
10191 enumeration maps are used (that is Image and Value attributes applied
10192 to enumeration types).
10193
10194 @node No_Exception_Handlers
10195 @unnumberedsubsec No_Exception_Handlers
10196 @findex No_Exception_Handlers
10197 [GNAT] This restriction ensures at compile time that there are no explicit
10198 exception handlers. It also indicates that no exception propagation will
10199 be provided. In this mode, exceptions may be raised but will result in
10200 an immediate call to the last chance handler, a routine that the user
10201 must define with the following profile:
10202
10203 @smallexample @c ada
10204 procedure Last_Chance_Handler
10205 (Source_Location : System.Address; Line : Integer);
10206 pragma Export (C, Last_Chance_Handler,
10207 "__gnat_last_chance_handler");
10208 @end smallexample
10209
10210 The parameter is a C null-terminated string representing a message to be
10211 associated with the exception (typically the source location of the raise
10212 statement generated by the compiler). The Line parameter when nonzero
10213 represents the line number in the source program where the raise occurs.
10214
10215 @node No_Exception_Propagation
10216 @unnumberedsubsec No_Exception_Propagation
10217 @findex No_Exception_Propagation
10218 [GNAT] This restriction guarantees that exceptions are never propagated
10219 to an outer subprogram scope. The only case in which an exception may
10220 be raised is when the handler is statically in the same subprogram, so
10221 that the effect of a raise is essentially like a goto statement. Any
10222 other raise statement (implicit or explicit) will be considered
10223 unhandled. Exception handlers are allowed, but may not contain an
10224 exception occurrence identifier (exception choice). In addition, use of
10225 the package GNAT.Current_Exception is not permitted, and reraise
10226 statements (raise with no operand) are not permitted.
10227
10228 @node No_Exception_Registration
10229 @unnumberedsubsec No_Exception_Registration
10230 @findex No_Exception_Registration
10231 [GNAT] This restriction ensures at compile time that no stream operations for
10232 types Exception_Id or Exception_Occurrence are used. This also makes it
10233 impossible to pass exceptions to or from a partition with this restriction
10234 in a distributed environment. If this exception is active, then the generated
10235 code is simplified by omitting the otherwise-required global registration
10236 of exceptions when they are declared.
10237
10238 @node No_Exceptions
10239 @unnumberedsubsec No_Exceptions
10240 @findex No_Exceptions
10241 [RM H.4] This restriction ensures at compile time that there are no
10242 raise statements and no exception handlers.
10243
10244 @node No_Finalization
10245 @unnumberedsubsec No_Finalization
10246 @findex No_Finalization
10247 [GNAT] This restriction disables the language features described in
10248 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
10249 performed by the compiler to support these features. The following types
10250 are no longer considered controlled when this restriction is in effect:
10251 @itemize @bullet
10252 @item
10253 @code{Ada.Finalization.Controlled}
10254 @item
10255 @code{Ada.Finalization.Limited_Controlled}
10256 @item
10257 Derivations from @code{Controlled} or @code{Limited_Controlled}
10258 @item
10259 Class-wide types
10260 @item
10261 Protected types
10262 @item
10263 Task types
10264 @item
10265 Array and record types with controlled components
10266 @end itemize
10267 The compiler no longer generates code to initialize, finalize or adjust an
10268 object or a nested component, either declared on the stack or on the heap. The
10269 deallocation of a controlled object no longer finalizes its contents.
10270
10271 @node No_Fixed_Point
10272 @unnumberedsubsec No_Fixed_Point
10273 @findex No_Fixed_Point
10274 [RM H.4] This restriction ensures at compile time that there are no
10275 occurrences of fixed point types and operations.
10276
10277 @node No_Floating_Point
10278 @unnumberedsubsec No_Floating_Point
10279 @findex No_Floating_Point
10280 [RM H.4] This restriction ensures at compile time that there are no
10281 occurrences of floating point types and operations.
10282
10283 @node No_Implicit_Conditionals
10284 @unnumberedsubsec No_Implicit_Conditionals
10285 @findex No_Implicit_Conditionals
10286 [GNAT] This restriction ensures that the generated code does not contain any
10287 implicit conditionals, either by modifying the generated code where possible,
10288 or by rejecting any construct that would otherwise generate an implicit
10289 conditional. Note that this check does not include run time constraint
10290 checks, which on some targets may generate implicit conditionals as
10291 well. To control the latter, constraint checks can be suppressed in the
10292 normal manner. Constructs generating implicit conditionals include comparisons
10293 of composite objects and the Max/Min attributes.
10294
10295 @node No_Implicit_Dynamic_Code
10296 @unnumberedsubsec No_Implicit_Dynamic_Code
10297 @findex No_Implicit_Dynamic_Code
10298 @cindex trampoline
10299 [GNAT] This restriction prevents the compiler from building ``trampolines''.
10300 This is a structure that is built on the stack and contains dynamic
10301 code to be executed at run time. On some targets, a trampoline is
10302 built for the following features: @code{Access},
10303 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
10304 nested task bodies; primitive operations of nested tagged types.
10305 Trampolines do not work on machines that prevent execution of stack
10306 data. For example, on windows systems, enabling DEP (data execution
10307 protection) will cause trampolines to raise an exception.
10308 Trampolines are also quite slow at run time.
10309
10310 On many targets, trampolines have been largely eliminated. Look at the
10311 version of system.ads for your target --- if it has
10312 Always_Compatible_Rep equal to False, then trampolines are largely
10313 eliminated. In particular, a trampoline is built for the following
10314 features: @code{Address} of a nested subprogram;
10315 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
10316 but only if pragma Favor_Top_Level applies, or the access type has a
10317 foreign-language convention; primitive operations of nested tagged
10318 types.
10319
10320 @node No_Implicit_Heap_Allocations
10321 @unnumberedsubsec No_Implicit_Heap_Allocations
10322 @findex No_Implicit_Heap_Allocations
10323 [RM D.7] No constructs are allowed to cause implicit heap allocation.
10324
10325 @node No_Implicit_Loops
10326 @unnumberedsubsec No_Implicit_Loops
10327 @findex No_Implicit_Loops
10328 [GNAT] This restriction ensures that the generated code does not contain any
10329 implicit @code{for} loops, either by modifying
10330 the generated code where possible,
10331 or by rejecting any construct that would otherwise generate an implicit
10332 @code{for} loop. If this restriction is active, it is possible to build
10333 large array aggregates with all static components without generating an
10334 intermediate temporary, and without generating a loop to initialize individual
10335 components. Otherwise, a loop is created for arrays larger than about 5000
10336 scalar components.
10337
10338 @node No_Initialize_Scalars
10339 @unnumberedsubsec No_Initialize_Scalars
10340 @findex No_Initialize_Scalars
10341 [GNAT] This restriction ensures that no unit in the partition is compiled with
10342 pragma Initialize_Scalars. This allows the generation of more efficient
10343 code, and in particular eliminates dummy null initialization routines that
10344 are otherwise generated for some record and array types.
10345
10346 @node No_IO
10347 @unnumberedsubsec No_IO
10348 @findex No_IO
10349 [RM H.4] This restriction ensures at compile time that there are no
10350 dependences on any of the library units Sequential_IO, Direct_IO,
10351 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
10352
10353 @node No_Local_Allocators
10354 @unnumberedsubsec No_Local_Allocators
10355 @findex No_Local_Allocators
10356 [RM H.4] This restriction ensures at compile time that there are no
10357 occurrences of an allocator in subprograms, generic subprograms, tasks,
10358 and entry bodies.
10359
10360 @node No_Local_Protected_Objects
10361 @unnumberedsubsec No_Local_Protected_Objects
10362 @findex No_Local_Protected_Objects
10363 [RM D.7] This restriction ensures at compile time that protected objects are
10364 only declared at the library level.
10365
10366 @node No_Local_Timing_Events
10367 @unnumberedsubsec No_Local_Timing_Events
10368 @findex No_Local_Timing_Events
10369 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
10370 declared at the library level.
10371
10372 @node No_Long_Long_Integers
10373 @unnumberedsubsec No_Long_Long_Integers
10374 @findex No_Long_Long_Integers
10375 [GNAT] This partition-wide restriction forbids any explicit reference to
10376 type Standard.Long_Long_Integer, and also forbids declaring range types whose
10377 implicit base type is Long_Long_Integer, and modular types whose size exceeds
10378 Long_Integer'Size.
10379
10380 @node No_Nested_Finalization
10381 @unnumberedsubsec No_Nested_Finalization
10382 @findex No_Nested_Finalization
10383 [RM D.7] All objects requiring finalization are declared at the library level.
10384
10385 @node No_Protected_Type_Allocators
10386 @unnumberedsubsec No_Protected_Type_Allocators
10387 @findex No_Protected_Type_Allocators
10388 [RM D.7] This restriction ensures at compile time that there are no allocator
10389 expressions that attempt to allocate protected objects.
10390
10391 @node No_Protected_Types
10392 @unnumberedsubsec No_Protected_Types
10393 @findex No_Protected_Types
10394 [RM H.4] This restriction ensures at compile time that there are no
10395 declarations of protected types or protected objects.
10396
10397 @node No_Recursion
10398 @unnumberedsubsec No_Recursion
10399 @findex No_Recursion
10400 [RM H.4] A program execution is erroneous if a subprogram is invoked as
10401 part of its execution.
10402
10403 @node No_Reentrancy
10404 @unnumberedsubsec No_Reentrancy
10405 @findex No_Reentrancy
10406 [RM H.4] A program execution is erroneous if a subprogram is executed by
10407 two tasks at the same time.
10408
10409 @node No_Relative_Delay
10410 @unnumberedsubsec No_Relative_Delay
10411 @findex No_Relative_Delay
10412 [RM D.7] This restriction ensures at compile time that there are no delay
10413 relative statements and prevents expressions such as @code{delay 1.23;} from
10414 appearing in source code.
10415
10416 @node No_Requeue_Statements
10417 @unnumberedsubsec No_Requeue_Statements
10418 @findex No_Requeue_Statements
10419 [RM D.7] This restriction ensures at compile time that no requeue statements
10420 are permitted and prevents keyword @code{requeue} from being used in source
10421 code.
10422
10423 @findex No_Requeue
10424 The restriction @code{No_Requeue} is recognized as a
10425 synonym for @code{No_Requeue_Statements}. This is retained for historical
10426 compatibility purposes (and a warning will be generated for its use if
10427 warnings on oNobsolescent features are activated).
10428
10429 @node No_Secondary_Stack
10430 @unnumberedsubsec No_Secondary_Stack
10431 @findex No_Secondary_Stack
10432 [GNAT] This restriction ensures at compile time that the generated code
10433 does not contain any reference to the secondary stack. The secondary
10434 stack is used to implement functions returning unconstrained objects
10435 (arrays or records) on some targets.
10436
10437 @node No_Select_Statements
10438 @unnumberedsubsec No_Select_Statements
10439 @findex No_Select_Statements
10440 [RM D.7] This restriction ensures at compile time no select statements of any
10441 kind are permitted, that is the keyword @code{select} may not appear.
10442
10443 @node No_Specific_Termination_Handlers
10444 @unnumberedsubsec No_Specific_Termination_Handlers
10445 @findex No_Specific_Termination_Handlers
10446 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
10447 or to Ada.Task_Termination.Specific_Handler.
10448
10449 @node No_Specification_of_Aspect
10450 @unnumberedsubsec No_Specification_of_Aspect
10451 @findex No_Specification_of_Aspect
10452 [RM 13.12.1] This restriction checks at compile time that no aspect
10453 specification, attribute definition clause, or pragma is given for a
10454 given aspect.
10455
10456 @node No_Standard_Allocators_After_Elaboration
10457 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
10458 @findex No_Standard_Allocators_After_Elaboration
10459 [RM D.7] Specifies that an allocator using a standard storage pool
10460 should never be evaluated at run time after the elaboration of the
10461 library items of the partition has completed. Otherwise, Storage_Error
10462 is raised.
10463
10464 @node No_Standard_Storage_Pools
10465 @unnumberedsubsec No_Standard_Storage_Pools
10466 @findex No_Standard_Storage_Pools
10467 [GNAT] This restriction ensures at compile time that no access types
10468 use the standard default storage pool. Any access type declared must
10469 have an explicit Storage_Pool attribute defined specifying a
10470 user-defined storage pool.
10471
10472 @node No_Stream_Optimizations
10473 @unnumberedsubsec No_Stream_Optimizations
10474 @findex No_Stream_Optimizations
10475 [GNAT] This restriction affects the performance of stream operations on types
10476 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
10477 compiler uses block reads and writes when manipulating @code{String} objects
10478 due to their supperior performance. When this restriction is in effect, the
10479 compiler performs all IO operations on a per-character basis.
10480
10481 @node No_Streams
10482 @unnumberedsubsec No_Streams
10483 @findex No_Streams
10484 [GNAT] This restriction ensures at compile/bind time that there are no
10485 stream objects created and no use of stream attributes.
10486 This restriction does not forbid dependences on the package
10487 @code{Ada.Streams}. So it is permissible to with
10488 @code{Ada.Streams} (or another package that does so itself)
10489 as long as no actual stream objects are created and no
10490 stream attributes are used.
10491
10492 Note that the use of restriction allows optimization of tagged types,
10493 since they do not need to worry about dispatching stream operations.
10494 To take maximum advantage of this space-saving optimization, any
10495 unit declaring a tagged type should be compiled with the restriction,
10496 though this is not required.
10497
10498 @node No_Task_Allocators
10499 @unnumberedsubsec No_Task_Allocators
10500 @findex No_Task_Allocators
10501 [RM D.7] There are no allocators for task types
10502 or types containing task subcomponents.
10503
10504 @node No_Task_Attributes_Package
10505 @unnumberedsubsec No_Task_Attributes_Package
10506 @findex No_Task_Attributes_Package
10507 [GNAT] This restriction ensures at compile time that there are no implicit or
10508 explicit dependencies on the package @code{Ada.Task_Attributes}.
10509
10510 @findex No_Task_Attributes
10511 The restriction @code{No_Task_Attributes} is recognized as a synonym
10512 for @code{No_Task_Attributes_Package}. This is retained for historical
10513 compatibility purposes (and a warning will be generated for its use if
10514 warnings on obsolescent features are activated).
10515
10516 @node No_Task_Hierarchy
10517 @unnumberedsubsec No_Task_Hierarchy
10518 @findex No_Task_Hierarchy
10519 [RM D.7] All (non-environment) tasks depend
10520 directly on the environment task of the partition.
10521
10522 @node No_Task_Termination
10523 @unnumberedsubsec No_Task_Termination
10524 @findex No_Task_Termination
10525 [RM D.7] Tasks which terminate are erroneous.
10526
10527 @node No_Tasking
10528 @unnumberedsubsec No_Tasking
10529 @findex No_Tasking
10530 [GNAT] This restriction prevents the declaration of tasks or task types
10531 throughout the partition. It is similar in effect to the use of
10532 @code{Max_Tasks => 0} except that violations are caught at compile time
10533 and cause an error message to be output either by the compiler or
10534 binder.
10535
10536 @node No_Terminate_Alternatives
10537 @unnumberedsubsec No_Terminate_Alternatives
10538 @findex No_Terminate_Alternatives
10539 [RM D.7] There are no selective accepts with terminate alternatives.
10540
10541 @node No_Unchecked_Access
10542 @unnumberedsubsec No_Unchecked_Access
10543 @findex No_Unchecked_Access
10544 [RM H.4] This restriction ensures at compile time that there are no
10545 occurrences of the Unchecked_Access attribute.
10546
10547 @node Simple_Barriers
10548 @unnumberedsubsec Simple_Barriers
10549 @findex Simple_Barriers
10550 [RM D.7] This restriction ensures at compile time that barriers in entry
10551 declarations for protected types are restricted to either static boolean
10552 expressions or references to simple boolean variables defined in the private
10553 part of the protected type. No other form of entry barriers is permitted.
10554
10555 @findex Boolean_Entry_Barriers
10556 The restriction @code{Boolean_Entry_Barriers} is recognized as a
10557 synonym for @code{Simple_Barriers}. This is retained for historical
10558 compatibility purposes (and a warning will be generated for its use if
10559 warnings on obsolescent features are activated).
10560
10561 @node Static_Priorities
10562 @unnumberedsubsec Static_Priorities
10563 @findex Static_Priorities
10564 [GNAT] This restriction ensures at compile time that all priority expressions
10565 are static, and that there are no dependences on the package
10566 @code{Ada.Dynamic_Priorities}.
10567
10568 @node Static_Storage_Size
10569 @unnumberedsubsec Static_Storage_Size
10570 @findex Static_Storage_Size
10571 [GNAT] This restriction ensures at compile time that any expression appearing
10572 in a Storage_Size pragma or attribute definition clause is static.
10573
10574 @node Program Unit Level Restrictions
10575 @section Program Unit Level Restrictions
10576
10577 @noindent
10578 The second set of restriction identifiers
10579 does not require partition-wide consistency.
10580 The restriction may be enforced for a single
10581 compilation unit without any effect on any of the
10582 other compilation units in the partition.
10583
10584 @menu
10585 * No_Elaboration_Code::
10586 * No_Entry_Queue::
10587 * No_Implementation_Aspect_Specifications::
10588 * No_Implementation_Attributes::
10589 * No_Implementation_Identifiers::
10590 * No_Implementation_Pragmas::
10591 * No_Implementation_Restrictions::
10592 * No_Implementation_Units::
10593 * No_Implicit_Aliasing::
10594 * No_Obsolescent_Features::
10595 * No_Wide_Characters::
10596 * SPARK_05::
10597 @end menu
10598
10599 @node No_Elaboration_Code
10600 @unnumberedsubsec No_Elaboration_Code
10601 @findex No_Elaboration_Code
10602 [GNAT] This restriction ensures at compile time that no elaboration code is
10603 generated. Note that this is not the same condition as is enforced
10604 by pragma @code{Preelaborate}. There are cases in which pragma
10605 @code{Preelaborate} still permits code to be generated (e.g.@: code
10606 to initialize a large array to all zeroes), and there are cases of units
10607 which do not meet the requirements for pragma @code{Preelaborate},
10608 but for which no elaboration code is generated. Generally, it is
10609 the case that preelaborable units will meet the restrictions, with
10610 the exception of large aggregates initialized with an others_clause,
10611 and exception declarations (which generate calls to a run-time
10612 registry procedure). This restriction is enforced on
10613 a unit by unit basis, it need not be obeyed consistently
10614 throughout a partition.
10615
10616 In the case of aggregates with others, if the aggregate has a dynamic
10617 size, there is no way to eliminate the elaboration code (such dynamic
10618 bounds would be incompatible with @code{Preelaborate} in any case). If
10619 the bounds are static, then use of this restriction actually modifies
10620 the code choice of the compiler to avoid generating a loop, and instead
10621 generate the aggregate statically if possible, no matter how many times
10622 the data for the others clause must be repeatedly generated.
10623
10624 It is not possible to precisely document
10625 the constructs which are compatible with this restriction, since,
10626 unlike most other restrictions, this is not a restriction on the
10627 source code, but a restriction on the generated object code. For
10628 example, if the source contains a declaration:
10629
10630 @smallexample
10631 Val : constant Integer := X;
10632 @end smallexample
10633
10634 @noindent
10635 where X is not a static constant, it may be possible, depending
10636 on complex optimization circuitry, for the compiler to figure
10637 out the value of X at compile time, in which case this initialization
10638 can be done by the loader, and requires no initialization code. It
10639 is not possible to document the precise conditions under which the
10640 optimizer can figure this out.
10641
10642 Note that this the implementation of this restriction requires full
10643 code generation. If it is used in conjunction with "semantics only"
10644 checking, then some cases of violations may be missed.
10645
10646 @node No_Entry_Queue
10647 @unnumberedsubsec No_Entry_Queue
10648 @findex No_Entry_Queue
10649 [GNAT] This restriction is a declaration that any protected entry compiled in
10650 the scope of the restriction has at most one task waiting on the entry
10651 at any one time, and so no queue is required. This restriction is not
10652 checked at compile time. A program execution is erroneous if an attempt
10653 is made to queue a second task on such an entry.
10654
10655 @node No_Implementation_Aspect_Specifications
10656 @unnumberedsubsec No_Implementation_Aspect_Specifications
10657 @findex No_Implementation_Aspect_Specifications
10658 [RM 13.12.1] This restriction checks at compile time that no
10659 GNAT-defined aspects are present. With this restriction, the only
10660 aspects that can be used are those defined in the Ada Reference Manual.
10661
10662 @node No_Implementation_Attributes
10663 @unnumberedsubsec No_Implementation_Attributes
10664 @findex No_Implementation_Attributes
10665 [RM 13.12.1] This restriction checks at compile time that no
10666 GNAT-defined attributes are present. With this restriction, the only
10667 attributes that can be used are those defined in the Ada Reference
10668 Manual.
10669
10670 @node No_Implementation_Identifiers
10671 @unnumberedsubsec No_Implementation_Identifiers
10672 @findex No_Implementation_Identifiers
10673 [RM 13.12.1] This restriction checks at compile time that no
10674 implementation-defined identifiers (marked with pragma Implementation_Defined)
10675 occur within language-defined packages.
10676
10677 @node No_Implementation_Pragmas
10678 @unnumberedsubsec No_Implementation_Pragmas
10679 @findex No_Implementation_Pragmas
10680 [RM 13.12.1] This restriction checks at compile time that no
10681 GNAT-defined pragmas are present. With this restriction, the only
10682 pragmas that can be used are those defined in the Ada Reference Manual.
10683
10684 @node No_Implementation_Restrictions
10685 @unnumberedsubsec No_Implementation_Restrictions
10686 @findex No_Implementation_Restrictions
10687 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
10688 identifiers (other than @code{No_Implementation_Restrictions} itself)
10689 are present. With this restriction, the only other restriction identifiers
10690 that can be used are those defined in the Ada Reference Manual.
10691
10692 @node No_Implementation_Units
10693 @unnumberedsubsec No_Implementation_Units
10694 @findex No_Implementation_Units
10695 [RM 13.12.1] This restriction checks at compile time that there is no
10696 mention in the context clause of any implementation-defined descendants
10697 of packages Ada, Interfaces, or System.
10698
10699 @node No_Implicit_Aliasing
10700 @unnumberedsubsec No_Implicit_Aliasing
10701 @findex No_Implicit_Aliasing
10702 [GNAT] This restriction, which is not required to be partition-wide consistent,
10703 requires an explicit aliased keyword for an object to which 'Access,
10704 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
10705 the 'Unrestricted_Access attribute for objects. Note: the reason that
10706 Unrestricted_Access is forbidden is that it would require the prefix
10707 to be aliased, and in such cases, it can always be replaced by
10708 the standard attribute Unchecked_Access which is preferable.
10709
10710 @node No_Obsolescent_Features
10711 @unnumberedsubsec No_Obsolescent_Features
10712 @findex No_Obsolescent_Features
10713 [RM 13.12.1] This restriction checks at compile time that no obsolescent
10714 features are used, as defined in Annex J of the Ada Reference Manual.
10715
10716 @node No_Wide_Characters
10717 @unnumberedsubsec No_Wide_Characters
10718 @findex No_Wide_Characters
10719 [GNAT] This restriction ensures at compile time that no uses of the types
10720 @code{Wide_Character} or @code{Wide_String} or corresponding wide
10721 wide types
10722 appear, and that no wide or wide wide string or character literals
10723 appear in the program (that is literals representing characters not in
10724 type @code{Character}).
10725
10726 @node SPARK_05
10727 @unnumberedsubsec SPARK_05
10728 @findex SPARK_05
10729 [GNAT] This restriction checks at compile time that some constructs
10730 forbidden in SPARK 2005 are not present. Error messages related to
10731 SPARK restriction have the form:
10732
10733 @findex SPARK
10734 The restriction @code{SPARK} is recognized as a
10735 synonym for @code{SPARK_05}. This is retained for historical
10736 compatibility purposes (and an unconditional warning will be generated
10737 for its use, advising replacement by @code{SPARK}.
10738
10739 @smallexample
10740 violation of restriction "SPARK" at <file>
10741 <error message>
10742 @end smallexample
10743
10744 This is not a replacement for the semantic checks performed by the
10745 SPARK Examiner tool, as the compiler currently only deals with code,
10746 not SPARK 2005 annotations, and does not guarantee catching all
10747 cases of constructs forbidden by SPARK 2005.
10748
10749 Thus it may well be the case that code which passes the compiler with
10750 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
10751 the different visibility rules of the Examiner based on SPARK 2005
10752 @code{inherit} annotations.
10753
10754 This restriction can be useful in providing an initial filter for code
10755 developed using SPARK 2005, or in examining legacy code to see how far
10756 it is from meeting SPARK restrictions.
10757
10758 The list below summarises the checks that are performed when this
10759 restriction is in force:
10760 @itemize @bullet
10761 @item No block statements
10762 @item No case statements with only an others clause
10763 @item Exit statements in loops must respect the SPARK 2005 language restrictions
10764 @item No goto statements
10765 @item Return can only appear as last statement in function
10766 @item Function must have return statement
10767 @item Loop parameter specification must include subtype mark
10768 @item Prefix of expanded name cannot be a loop statement
10769 @item Abstract subprogram not allowed
10770 @item User-defined operators not allowed
10771 @item Access type parameters not allowed
10772 @item Default expressions for parameters not allowed
10773 @item Default expressions for record fields not allowed
10774 @item No tasking constructs allowed
10775 @item Label needed at end of subprograms and packages
10776 @item No mixing of positional and named parameter association
10777 @item No access types as result type
10778 @item No unconstrained arrays as result types
10779 @item No null procedures
10780 @item Initial and later declarations must be in correct order (declaration can't come after body)
10781 @item No attributes on private types if full declaration not visible
10782 @item No package declaration within package specification
10783 @item No controlled types
10784 @item No discriminant types
10785 @item No overloading
10786 @item Selector name cannot be operator symbol (i.e. operator symbol cannot be prefixed)
10787 @item Access attribute not allowed
10788 @item Allocator not allowed
10789 @item Result of catenation must be String
10790 @item Operands of catenation must be string literal, static char or another catenation
10791 @item No conditional expressions
10792 @item No explicit dereference
10793 @item Quantified expression not allowed
10794 @item Slicing not allowed
10795 @item No exception renaming
10796 @item No generic renaming
10797 @item No object renaming
10798 @item No use clause
10799 @item Aggregates must be qualified
10800 @item Non-static choice in array aggregates not allowed
10801 @item The only view conversions which are allowed as in-out parameters are conversions of a tagged type to an ancestor type
10802 @item No mixing of positional and named association in aggregate, no multi choice
10803 @item AND, OR and XOR for arrays only allowed when operands have same static bounds
10804 @item Fixed point operands to * or / must be qualified or converted
10805 @item Comparison operators not allowed for Booleans or arrays (except strings)
10806 @item Equality not allowed for arrays with non-matching static bounds (except strings)
10807 @item Conversion / qualification not allowed for arrays with non-matching static bounds
10808 @item Subprogram declaration only allowed in package spec (unless followed by import)
10809 @item Access types not allowed
10810 @item Incomplete type declaration not allowed
10811 @item Object and subtype declarations must respect SPARK restrictions
10812 @item Digits or delta constraint not allowed
10813 @item Decimal fixed point type not allowed
10814 @item Aliasing of objects not allowed
10815 @item Modular type modulus must be power of 2
10816 @item Base not allowed on subtype mark
10817 @item Unary operators not allowed on modular types (except not)
10818 @item Non-tagged record cannot be null
10819 @item No class-wide operations
10820 @item Initialization expressions must respect SPARK restrictions
10821 @item Non-static ranges not allowed except in iteration schemes
10822 @item String subtypes must have lower bound of 1
10823 @item Subtype of Boolean cannot have constraint
10824 @item At most one tagged type or extension per package
10825 @item Interface is not allowed
10826 @item Character literal cannot be prefixed (selector name cannot be character literal)
10827 @item Record aggregate cannot contain 'others'
10828 @item Component association in record aggregate must contain a single choice
10829 @item Ancestor part cannot be a type mark
10830 @item Attributes 'Image, 'Width and 'Value not allowed
10831 @item Functions may not update globals
10832 @item Subprograms may not contain direct calls to themselves (prevents recursion within unit)
10833 @item Call to subprogram not allowed in same unit before body has been seen (prevents recursion within unit)
10834 @end itemize
10835
10836 The following restrictions are enforced, but note that they are actually more
10837 strict that the latest SPARK 2005 language definition:
10838
10839 @itemize @bullet
10840 @item No derived types other than tagged type extensions
10841 @item Subtype of unconstrained array must have constraint
10842 @end itemize
10843
10844 This list summarises the main SPARK 2005 language rules that are not
10845 currently checked by the SPARK_05 restriction:
10846
10847 @itemize @bullet
10848 @item SPARK annotations are treated as comments so are not checked at all
10849 @item Based real literals not allowed
10850 @item Objects cannot be initialized at declaration by calls to user-defined functions
10851 @item Objects cannot be initialized at declaration by assignments from variables
10852 @item Objects cannot be initialized at declaration by assignments from indexed/selected components
10853 @item Ranges shall not be null
10854 @item A fixed point delta expression must be a simple expression
10855 @item Restrictions on where renaming declarations may be placed
10856 @item Externals of mode 'out' cannot be referenced
10857 @item Externals of mode 'in' cannot be updated
10858 @item Loop with no iteration scheme or exits only allowed as last statement in main program or task
10859 @item Subprogram cannot have parent unit name
10860 @item SPARK 2005 inherited subprogram must be prefixed with overriding
10861 @item External variables (or functions that reference them) may not be passed as actual parameters
10862 @item Globals must be explicitly mentioned in contract
10863 @item Deferred constants cannot be completed by pragma Import
10864 @item Package initialization cannot read/write variables from other packages
10865 @item Prefix not allowed for entities that are directly visible
10866 @item Identifier declaration can't override inherited package name
10867 @item Cannot use Standard or other predefined packages as identifiers
10868 @item After renaming, cannot use the original name
10869 @item Subprograms can only be renamed to remove package prefix
10870 @item Pragma import must be immediately after entity it names
10871 @item No mutual recursion between multiple units (this can be checked with gnatcheck)
10872 @end itemize
10873
10874 Note that if a unit is compiled in Ada 95 mode with the SPARK restriction,
10875 violations will be reported for constructs forbidden in SPARK 95,
10876 instead of SPARK 2005.
10877
10878 @c ------------------------
10879 @node Implementation Advice
10880 @chapter Implementation Advice
10881 @noindent
10882 The main text of the Ada Reference Manual describes the required
10883 behavior of all Ada compilers, and the GNAT compiler conforms to
10884 these requirements.
10885
10886 In addition, there are sections throughout the Ada Reference Manual headed
10887 by the phrase ``Implementation advice''. These sections are not normative,
10888 i.e., they do not specify requirements that all compilers must
10889 follow. Rather they provide advice on generally desirable behavior. You
10890 may wonder why they are not requirements. The most typical answer is
10891 that they describe behavior that seems generally desirable, but cannot
10892 be provided on all systems, or which may be undesirable on some systems.
10893
10894 As far as practical, GNAT follows the implementation advice sections in
10895 the Ada Reference Manual. This chapter contains a table giving the
10896 reference manual section number, paragraph number and several keywords
10897 for each advice. Each entry consists of the text of the advice followed
10898 by the GNAT interpretation of this advice. Most often, this simply says
10899 ``followed'', which means that GNAT follows the advice. However, in a
10900 number of cases, GNAT deliberately deviates from this advice, in which
10901 case the text describes what GNAT does and why.
10902
10903 @cindex Error detection
10904 @unnumberedsec 1.1.3(20): Error Detection
10905 @sp 1
10906 @cartouche
10907 If an implementation detects the use of an unsupported Specialized Needs
10908 Annex feature at run time, it should raise @code{Program_Error} if
10909 feasible.
10910 @end cartouche
10911 Not relevant. All specialized needs annex features are either supported,
10912 or diagnosed at compile time.
10913
10914 @cindex Child Units
10915 @unnumberedsec 1.1.3(31): Child Units
10916 @sp 1
10917 @cartouche
10918 If an implementation wishes to provide implementation-defined
10919 extensions to the functionality of a language-defined library unit, it
10920 should normally do so by adding children to the library unit.
10921 @end cartouche
10922 Followed.
10923
10924 @cindex Bounded errors
10925 @unnumberedsec 1.1.5(12): Bounded Errors
10926 @sp 1
10927 @cartouche
10928 If an implementation detects a bounded error or erroneous
10929 execution, it should raise @code{Program_Error}.
10930 @end cartouche
10931 Followed in all cases in which the implementation detects a bounded
10932 error or erroneous execution. Not all such situations are detected at
10933 runtime.
10934
10935 @cindex Pragmas
10936 @unnumberedsec 2.8(16): Pragmas
10937 @sp 1
10938 @cartouche
10939 Normally, implementation-defined pragmas should have no semantic effect
10940 for error-free programs; that is, if the implementation-defined pragmas
10941 are removed from a working program, the program should still be legal,
10942 and should still have the same semantics.
10943 @end cartouche
10944 The following implementation defined pragmas are exceptions to this
10945 rule:
10946
10947 @table @code
10948 @item Abort_Defer
10949 Affects semantics
10950 @item Ada_83
10951 Affects legality
10952 @item Assert
10953 Affects semantics
10954 @item CPP_Class
10955 Affects semantics
10956 @item CPP_Constructor
10957 Affects semantics
10958 @item Debug
10959 Affects semantics
10960 @item Interface_Name
10961 Affects semantics
10962 @item Machine_Attribute
10963 Affects semantics
10964 @item Unimplemented_Unit
10965 Affects legality
10966 @item Unchecked_Union
10967 Affects semantics
10968 @end table
10969
10970 @noindent
10971 In each of the above cases, it is essential to the purpose of the pragma
10972 that this advice not be followed. For details see the separate section
10973 on implementation defined pragmas.
10974
10975 @unnumberedsec 2.8(17-19): Pragmas
10976 @sp 1
10977 @cartouche
10978 Normally, an implementation should not define pragmas that can
10979 make an illegal program legal, except as follows:
10980 @end cartouche
10981 @sp 1
10982 @cartouche
10983 A pragma used to complete a declaration, such as a pragma @code{Import};
10984 @end cartouche
10985 @sp 1
10986 @cartouche
10987 A pragma used to configure the environment by adding, removing, or
10988 replacing @code{library_items}.
10989 @end cartouche
10990 See response to paragraph 16 of this same section.
10991
10992 @cindex Character Sets
10993 @cindex Alternative Character Sets
10994 @unnumberedsec 3.5.2(5): Alternative Character Sets
10995 @sp 1
10996 @cartouche
10997 If an implementation supports a mode with alternative interpretations
10998 for @code{Character} and @code{Wide_Character}, the set of graphic
10999 characters of @code{Character} should nevertheless remain a proper
11000 subset of the set of graphic characters of @code{Wide_Character}. Any
11001 character set ``localizations'' should be reflected in the results of
11002 the subprograms defined in the language-defined package
11003 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
11004 an alternative interpretation of @code{Character}, the implementation should
11005 also support a corresponding change in what is a legal
11006 @code{identifier_letter}.
11007 @end cartouche
11008 Not all wide character modes follow this advice, in particular the JIS
11009 and IEC modes reflect standard usage in Japan, and in these encoding,
11010 the upper half of the Latin-1 set is not part of the wide-character
11011 subset, since the most significant bit is used for wide character
11012 encoding. However, this only applies to the external forms. Internally
11013 there is no such restriction.
11014
11015 @cindex Integer types
11016 @unnumberedsec 3.5.4(28): Integer Types
11017
11018 @sp 1
11019 @cartouche
11020 An implementation should support @code{Long_Integer} in addition to
11021 @code{Integer} if the target machine supports 32-bit (or longer)
11022 arithmetic. No other named integer subtypes are recommended for package
11023 @code{Standard}. Instead, appropriate named integer subtypes should be
11024 provided in the library package @code{Interfaces} (see B.2).
11025 @end cartouche
11026 @code{Long_Integer} is supported. Other standard integer types are supported
11027 so this advice is not fully followed. These types
11028 are supported for convenient interface to C, and so that all hardware
11029 types of the machine are easily available.
11030 @unnumberedsec 3.5.4(29): Integer Types
11031
11032 @sp 1
11033 @cartouche
11034 An implementation for a two's complement machine should support
11035 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
11036 implementation should support a non-binary modules up to @code{Integer'Last}.
11037 @end cartouche
11038 Followed.
11039
11040 @cindex Enumeration values
11041 @unnumberedsec 3.5.5(8): Enumeration Values
11042 @sp 1
11043 @cartouche
11044 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
11045 subtype, if the value of the operand does not correspond to the internal
11046 code for any enumeration literal of its type (perhaps due to an
11047 un-initialized variable), then the implementation should raise
11048 @code{Program_Error}. This is particularly important for enumeration
11049 types with noncontiguous internal codes specified by an
11050 enumeration_representation_clause.
11051 @end cartouche
11052 Followed.
11053
11054 @cindex Float types
11055 @unnumberedsec 3.5.7(17): Float Types
11056 @sp 1
11057 @cartouche
11058 An implementation should support @code{Long_Float} in addition to
11059 @code{Float} if the target machine supports 11 or more digits of
11060 precision. No other named floating point subtypes are recommended for
11061 package @code{Standard}. Instead, appropriate named floating point subtypes
11062 should be provided in the library package @code{Interfaces} (see B.2).
11063 @end cartouche
11064 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
11065 former provides improved compatibility with other implementations
11066 supporting this type. The latter corresponds to the highest precision
11067 floating-point type supported by the hardware. On most machines, this
11068 will be the same as @code{Long_Float}, but on some machines, it will
11069 correspond to the IEEE extended form. The notable case is all ia32
11070 (x86) implementations, where @code{Long_Long_Float} corresponds to
11071 the 80-bit extended precision format supported in hardware on this
11072 processor. Note that the 128-bit format on SPARC is not supported,
11073 since this is a software rather than a hardware format.
11074
11075 @cindex Multidimensional arrays
11076 @cindex Arrays, multidimensional
11077 @unnumberedsec 3.6.2(11): Multidimensional Arrays
11078 @sp 1
11079 @cartouche
11080 An implementation should normally represent multidimensional arrays in
11081 row-major order, consistent with the notation used for multidimensional
11082 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
11083 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
11084 column-major order should be used instead (see B.5, ``Interfacing with
11085 Fortran'').
11086 @end cartouche
11087 Followed.
11088
11089 @findex Duration'Small
11090 @unnumberedsec 9.6(30-31): Duration'Small
11091 @sp 1
11092 @cartouche
11093 Whenever possible in an implementation, the value of @code{Duration'Small}
11094 should be no greater than 100 microseconds.
11095 @end cartouche
11096 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
11097
11098 @sp 1
11099 @cartouche
11100 The time base for @code{delay_relative_statements} should be monotonic;
11101 it need not be the same time base as used for @code{Calendar.Clock}.
11102 @end cartouche
11103 Followed.
11104
11105 @unnumberedsec 10.2.1(12): Consistent Representation
11106 @sp 1
11107 @cartouche
11108 In an implementation, a type declared in a pre-elaborated package should
11109 have the same representation in every elaboration of a given version of
11110 the package, whether the elaborations occur in distinct executions of
11111 the same program, or in executions of distinct programs or partitions
11112 that include the given version.
11113 @end cartouche
11114 Followed, except in the case of tagged types. Tagged types involve
11115 implicit pointers to a local copy of a dispatch table, and these pointers
11116 have representations which thus depend on a particular elaboration of the
11117 package. It is not easy to see how it would be possible to follow this
11118 advice without severely impacting efficiency of execution.
11119
11120 @cindex Exception information
11121 @unnumberedsec 11.4.1(19): Exception Information
11122 @sp 1
11123 @cartouche
11124 @code{Exception_Message} by default and @code{Exception_Information}
11125 should produce information useful for
11126 debugging. @code{Exception_Message} should be short, about one
11127 line. @code{Exception_Information} can be long. @code{Exception_Message}
11128 should not include the
11129 @code{Exception_Name}. @code{Exception_Information} should include both
11130 the @code{Exception_Name} and the @code{Exception_Message}.
11131 @end cartouche
11132 Followed. For each exception that doesn't have a specified
11133 @code{Exception_Message}, the compiler generates one containing the location
11134 of the raise statement. This location has the form ``file:line'', where
11135 file is the short file name (without path information) and line is the line
11136 number in the file. Note that in the case of the Zero Cost Exception
11137 mechanism, these messages become redundant with the Exception_Information that
11138 contains a full backtrace of the calling sequence, so they are disabled.
11139 To disable explicitly the generation of the source location message, use the
11140 Pragma @code{Discard_Names}.
11141
11142 @cindex Suppression of checks
11143 @cindex Checks, suppression of
11144 @unnumberedsec 11.5(28): Suppression of Checks
11145 @sp 1
11146 @cartouche
11147 The implementation should minimize the code executed for checks that
11148 have been suppressed.
11149 @end cartouche
11150 Followed.
11151
11152 @cindex Representation clauses
11153 @unnumberedsec 13.1 (21-24): Representation Clauses
11154 @sp 1
11155 @cartouche
11156 The recommended level of support for all representation items is
11157 qualified as follows:
11158 @end cartouche
11159 @sp 1
11160 @cartouche
11161 An implementation need not support representation items containing
11162 non-static expressions, except that an implementation should support a
11163 representation item for a given entity if each non-static expression in
11164 the representation item is a name that statically denotes a constant
11165 declared before the entity.
11166 @end cartouche
11167 Followed. In fact, GNAT goes beyond the recommended level of support
11168 by allowing nonstatic expressions in some representation clauses even
11169 without the need to declare constants initialized with the values of
11170 such expressions.
11171 For example:
11172
11173 @smallexample @c ada
11174 X : Integer;
11175 Y : Float;
11176 for Y'Address use X'Address;>>
11177 @end smallexample
11178
11179 @sp 1
11180 @cartouche
11181 An implementation need not support a specification for the @code{Size}
11182 for a given composite subtype, nor the size or storage place for an
11183 object (including a component) of a given composite subtype, unless the
11184 constraints on the subtype and its composite subcomponents (if any) are
11185 all static constraints.
11186 @end cartouche
11187 Followed. Size Clauses are not permitted on non-static components, as
11188 described above.
11189
11190 @sp 1
11191 @cartouche
11192 An aliased component, or a component whose type is by-reference, should
11193 always be allocated at an addressable location.
11194 @end cartouche
11195 Followed.
11196
11197 @cindex Packed types
11198 @unnumberedsec 13.2(6-8): Packed Types
11199 @sp 1
11200 @cartouche
11201 If a type is packed, then the implementation should try to minimize
11202 storage allocated to objects of the type, possibly at the expense of
11203 speed of accessing components, subject to reasonable complexity in
11204 addressing calculations.
11205 @end cartouche
11206 @sp 1
11207 @cartouche
11208 The recommended level of support pragma @code{Pack} is:
11209
11210 For a packed record type, the components should be packed as tightly as
11211 possible subject to the Sizes of the component subtypes, and subject to
11212 any @code{record_representation_clause} that applies to the type; the
11213 implementation may, but need not, reorder components or cross aligned
11214 word boundaries to improve the packing. A component whose @code{Size} is
11215 greater than the word size may be allocated an integral number of words.
11216 @end cartouche
11217 Followed. Tight packing of arrays is supported for all component sizes
11218 up to 64-bits. If the array component size is 1 (that is to say, if
11219 the component is a boolean type or an enumeration type with two values)
11220 then values of the type are implicitly initialized to zero. This
11221 happens both for objects of the packed type, and for objects that have a
11222 subcomponent of the packed type.
11223
11224 @sp 1
11225 @cartouche
11226 An implementation should support Address clauses for imported
11227 subprograms.
11228 @end cartouche
11229 Followed.
11230 @cindex @code{Address} clauses
11231 @unnumberedsec 13.3(14-19): Address Clauses
11232
11233 @sp 1
11234 @cartouche
11235 For an array @var{X}, @code{@var{X}'Address} should point at the first
11236 component of the array, and not at the array bounds.
11237 @end cartouche
11238 Followed.
11239
11240 @sp 1
11241 @cartouche
11242 The recommended level of support for the @code{Address} attribute is:
11243
11244 @code{@var{X}'Address} should produce a useful result if @var{X} is an
11245 object that is aliased or of a by-reference type, or is an entity whose
11246 @code{Address} has been specified.
11247 @end cartouche
11248 Followed. A valid address will be produced even if none of those
11249 conditions have been met. If necessary, the object is forced into
11250 memory to ensure the address is valid.
11251
11252 @sp 1
11253 @cartouche
11254 An implementation should support @code{Address} clauses for imported
11255 subprograms.
11256 @end cartouche
11257 Followed.
11258
11259 @sp 1
11260 @cartouche
11261 Objects (including subcomponents) that are aliased or of a by-reference
11262 type should be allocated on storage element boundaries.
11263 @end cartouche
11264 Followed.
11265
11266 @sp 1
11267 @cartouche
11268 If the @code{Address} of an object is specified, or it is imported or exported,
11269 then the implementation should not perform optimizations based on
11270 assumptions of no aliases.
11271 @end cartouche
11272 Followed.
11273
11274 @cindex @code{Alignment} clauses
11275 @unnumberedsec 13.3(29-35): Alignment Clauses
11276 @sp 1
11277 @cartouche
11278 The recommended level of support for the @code{Alignment} attribute for
11279 subtypes is:
11280
11281 An implementation should support specified Alignments that are factors
11282 and multiples of the number of storage elements per word, subject to the
11283 following:
11284 @end cartouche
11285 Followed.
11286
11287 @sp 1
11288 @cartouche
11289 An implementation need not support specified @code{Alignment}s for
11290 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
11291 loaded and stored by available machine instructions.
11292 @end cartouche
11293 Followed.
11294
11295 @sp 1
11296 @cartouche
11297 An implementation need not support specified @code{Alignment}s that are
11298 greater than the maximum @code{Alignment} the implementation ever returns by
11299 default.
11300 @end cartouche
11301 Followed.
11302
11303 @sp 1
11304 @cartouche
11305 The recommended level of support for the @code{Alignment} attribute for
11306 objects is:
11307
11308 Same as above, for subtypes, but in addition:
11309 @end cartouche
11310 Followed.
11311
11312 @sp 1
11313 @cartouche
11314 For stand-alone library-level objects of statically constrained
11315 subtypes, the implementation should support all @code{Alignment}s
11316 supported by the target linker. For example, page alignment is likely to
11317 be supported for such objects, but not for subtypes.
11318 @end cartouche
11319 Followed.
11320
11321 @cindex @code{Size} clauses
11322 @unnumberedsec 13.3(42-43): Size Clauses
11323 @sp 1
11324 @cartouche
11325 The recommended level of support for the @code{Size} attribute of
11326 objects is:
11327
11328 A @code{Size} clause should be supported for an object if the specified
11329 @code{Size} is at least as large as its subtype's @code{Size}, and
11330 corresponds to a size in storage elements that is a multiple of the
11331 object's @code{Alignment} (if the @code{Alignment} is nonzero).
11332 @end cartouche
11333 Followed.
11334
11335 @unnumberedsec 13.3(50-56): Size Clauses
11336 @sp 1
11337 @cartouche
11338 If the @code{Size} of a subtype is specified, and allows for efficient
11339 independent addressability (see 9.10) on the target architecture, then
11340 the @code{Size} of the following objects of the subtype should equal the
11341 @code{Size} of the subtype:
11342
11343 Aliased objects (including components).
11344 @end cartouche
11345 Followed.
11346
11347 @sp 1
11348 @cartouche
11349 @code{Size} clause on a composite subtype should not affect the
11350 internal layout of components.
11351 @end cartouche
11352 Followed. But note that this can be overridden by use of the implementation
11353 pragma Implicit_Packing in the case of packed arrays.
11354
11355 @sp 1
11356 @cartouche
11357 The recommended level of support for the @code{Size} attribute of subtypes is:
11358 @end cartouche
11359 @sp 1
11360 @cartouche
11361 The @code{Size} (if not specified) of a static discrete or fixed point
11362 subtype should be the number of bits needed to represent each value
11363 belonging to the subtype using an unbiased representation, leaving space
11364 for a sign bit only if the subtype contains negative values. If such a
11365 subtype is a first subtype, then an implementation should support a
11366 specified @code{Size} for it that reflects this representation.
11367 @end cartouche
11368 Followed.
11369
11370 @sp 1
11371 @cartouche
11372 For a subtype implemented with levels of indirection, the @code{Size}
11373 should include the size of the pointers, but not the size of what they
11374 point at.
11375 @end cartouche
11376 Followed.
11377
11378 @cindex @code{Component_Size} clauses
11379 @unnumberedsec 13.3(71-73): Component Size Clauses
11380 @sp 1
11381 @cartouche
11382 The recommended level of support for the @code{Component_Size}
11383 attribute is:
11384 @end cartouche
11385 @sp 1
11386 @cartouche
11387 An implementation need not support specified @code{Component_Sizes} that are
11388 less than the @code{Size} of the component subtype.
11389 @end cartouche
11390 Followed.
11391
11392 @sp 1
11393 @cartouche
11394 An implementation should support specified @code{Component_Size}s that
11395 are factors and multiples of the word size. For such
11396 @code{Component_Size}s, the array should contain no gaps between
11397 components. For other @code{Component_Size}s (if supported), the array
11398 should contain no gaps between components when packing is also
11399 specified; the implementation should forbid this combination in cases
11400 where it cannot support a no-gaps representation.
11401 @end cartouche
11402 Followed.
11403
11404 @cindex Enumeration representation clauses
11405 @cindex Representation clauses, enumeration
11406 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
11407 @sp 1
11408 @cartouche
11409 The recommended level of support for enumeration representation clauses
11410 is:
11411
11412 An implementation need not support enumeration representation clauses
11413 for boolean types, but should at minimum support the internal codes in
11414 the range @code{System.Min_Int.System.Max_Int}.
11415 @end cartouche
11416 Followed.
11417
11418 @cindex Record representation clauses
11419 @cindex Representation clauses, records
11420 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
11421 @sp 1
11422 @cartouche
11423 The recommended level of support for
11424 @*@code{record_representation_clauses} is:
11425
11426 An implementation should support storage places that can be extracted
11427 with a load, mask, shift sequence of machine code, and set with a load,
11428 shift, mask, store sequence, given the available machine instructions
11429 and run-time model.
11430 @end cartouche
11431 Followed.
11432
11433 @sp 1
11434 @cartouche
11435 A storage place should be supported if its size is equal to the
11436 @code{Size} of the component subtype, and it starts and ends on a
11437 boundary that obeys the @code{Alignment} of the component subtype.
11438 @end cartouche
11439 Followed.
11440
11441 @sp 1
11442 @cartouche
11443 If the default bit ordering applies to the declaration of a given type,
11444 then for a component whose subtype's @code{Size} is less than the word
11445 size, any storage place that does not cross an aligned word boundary
11446 should be supported.
11447 @end cartouche
11448 Followed.
11449
11450 @sp 1
11451 @cartouche
11452 An implementation may reserve a storage place for the tag field of a
11453 tagged type, and disallow other components from overlapping that place.
11454 @end cartouche
11455 Followed. The storage place for the tag field is the beginning of the tagged
11456 record, and its size is Address'Size. GNAT will reject an explicit component
11457 clause for the tag field.
11458
11459 @sp 1
11460 @cartouche
11461 An implementation need not support a @code{component_clause} for a
11462 component of an extension part if the storage place is not after the
11463 storage places of all components of the parent type, whether or not
11464 those storage places had been specified.
11465 @end cartouche
11466 Followed. The above advice on record representation clauses is followed,
11467 and all mentioned features are implemented.
11468
11469 @cindex Storage place attributes
11470 @unnumberedsec 13.5.2(5): Storage Place Attributes
11471 @sp 1
11472 @cartouche
11473 If a component is represented using some form of pointer (such as an
11474 offset) to the actual data of the component, and this data is contiguous
11475 with the rest of the object, then the storage place attributes should
11476 reflect the place of the actual data, not the pointer. If a component is
11477 allocated discontinuously from the rest of the object, then a warning
11478 should be generated upon reference to one of its storage place
11479 attributes.
11480 @end cartouche
11481 Followed. There are no such components in GNAT@.
11482
11483 @cindex Bit ordering
11484 @unnumberedsec 13.5.3(7-8): Bit Ordering
11485 @sp 1
11486 @cartouche
11487 The recommended level of support for the non-default bit ordering is:
11488 @end cartouche
11489 @sp 1
11490 @cartouche
11491 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
11492 should support the non-default bit ordering in addition to the default
11493 bit ordering.
11494 @end cartouche
11495 Followed. Word size does not equal storage size in this implementation.
11496 Thus non-default bit ordering is not supported.
11497
11498 @cindex @code{Address}, as private type
11499 @unnumberedsec 13.7(37): Address as Private
11500 @sp 1
11501 @cartouche
11502 @code{Address} should be of a private type.
11503 @end cartouche
11504 Followed.
11505
11506 @cindex Operations, on @code{Address}
11507 @cindex @code{Address}, operations of
11508 @unnumberedsec 13.7.1(16): Address Operations
11509 @sp 1
11510 @cartouche
11511 Operations in @code{System} and its children should reflect the target
11512 environment semantics as closely as is reasonable. For example, on most
11513 machines, it makes sense for address arithmetic to ``wrap around''.
11514 Operations that do not make sense should raise @code{Program_Error}.
11515 @end cartouche
11516 Followed. Address arithmetic is modular arithmetic that wraps around. No
11517 operation raises @code{Program_Error}, since all operations make sense.
11518
11519 @cindex Unchecked conversion
11520 @unnumberedsec 13.9(14-17): Unchecked Conversion
11521 @sp 1
11522 @cartouche
11523 The @code{Size} of an array object should not include its bounds; hence,
11524 the bounds should not be part of the converted data.
11525 @end cartouche
11526 Followed.
11527
11528 @sp 1
11529 @cartouche
11530 The implementation should not generate unnecessary run-time checks to
11531 ensure that the representation of @var{S} is a representation of the
11532 target type. It should take advantage of the permission to return by
11533 reference when possible. Restrictions on unchecked conversions should be
11534 avoided unless required by the target environment.
11535 @end cartouche
11536 Followed. There are no restrictions on unchecked conversion. A warning is
11537 generated if the source and target types do not have the same size since
11538 the semantics in this case may be target dependent.
11539
11540 @sp 1
11541 @cartouche
11542 The recommended level of support for unchecked conversions is:
11543 @end cartouche
11544 @sp 1
11545 @cartouche
11546 Unchecked conversions should be supported and should be reversible in
11547 the cases where this clause defines the result. To enable meaningful use
11548 of unchecked conversion, a contiguous representation should be used for
11549 elementary subtypes, for statically constrained array subtypes whose
11550 component subtype is one of the subtypes described in this paragraph,
11551 and for record subtypes without discriminants whose component subtypes
11552 are described in this paragraph.
11553 @end cartouche
11554 Followed.
11555
11556 @cindex Heap usage, implicit
11557 @unnumberedsec 13.11(23-25): Implicit Heap Usage
11558 @sp 1
11559 @cartouche
11560 An implementation should document any cases in which it dynamically
11561 allocates heap storage for a purpose other than the evaluation of an
11562 allocator.
11563 @end cartouche
11564 Followed, the only other points at which heap storage is dynamically
11565 allocated are as follows:
11566
11567 @itemize @bullet
11568 @item
11569 At initial elaboration time, to allocate dynamically sized global
11570 objects.
11571
11572 @item
11573 To allocate space for a task when a task is created.
11574
11575 @item
11576 To extend the secondary stack dynamically when needed. The secondary
11577 stack is used for returning variable length results.
11578 @end itemize
11579
11580 @sp 1
11581 @cartouche
11582 A default (implementation-provided) storage pool for an
11583 access-to-constant type should not have overhead to support deallocation of
11584 individual objects.
11585 @end cartouche
11586 Followed.
11587
11588 @sp 1
11589 @cartouche
11590 A storage pool for an anonymous access type should be created at the
11591 point of an allocator for the type, and be reclaimed when the designated
11592 object becomes inaccessible.
11593 @end cartouche
11594 Followed.
11595
11596 @cindex Unchecked deallocation
11597 @unnumberedsec 13.11.2(17): Unchecked De-allocation
11598 @sp 1
11599 @cartouche
11600 For a standard storage pool, @code{Free} should actually reclaim the
11601 storage.
11602 @end cartouche
11603 Followed.
11604
11605 @cindex Stream oriented attributes
11606 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
11607 @sp 1
11608 @cartouche
11609 If a stream element is the same size as a storage element, then the
11610 normal in-memory representation should be used by @code{Read} and
11611 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
11612 should use the smallest number of stream elements needed to represent
11613 all values in the base range of the scalar type.
11614 @end cartouche
11615
11616 Followed. By default, GNAT uses the interpretation suggested by AI-195,
11617 which specifies using the size of the first subtype.
11618 However, such an implementation is based on direct binary
11619 representations and is therefore target- and endianness-dependent.
11620 To address this issue, GNAT also supplies an alternate implementation
11621 of the stream attributes @code{Read} and @code{Write},
11622 which uses the target-independent XDR standard representation
11623 for scalar types.
11624 @cindex XDR representation
11625 @cindex @code{Read} attribute
11626 @cindex @code{Write} attribute
11627 @cindex Stream oriented attributes
11628 The XDR implementation is provided as an alternative body of the
11629 @code{System.Stream_Attributes} package, in the file
11630 @file{s-stratt-xdr.adb} in the GNAT library.
11631 There is no @file{s-stratt-xdr.ads} file.
11632 In order to install the XDR implementation, do the following:
11633 @enumerate
11634 @item Replace the default implementation of the
11635 @code{System.Stream_Attributes} package with the XDR implementation.
11636 For example on a Unix platform issue the commands:
11637 @smallexample
11638 $ mv s-stratt.adb s-stratt-default.adb
11639 $ mv s-stratt-xdr.adb s-stratt.adb
11640 @end smallexample
11641
11642 @item
11643 Rebuild the GNAT run-time library as documented in
11644 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
11645 @end enumerate
11646
11647 @unnumberedsec A.1(52): Names of Predefined Numeric Types
11648 @sp 1
11649 @cartouche
11650 If an implementation provides additional named predefined integer types,
11651 then the names should end with @samp{Integer} as in
11652 @samp{Long_Integer}. If an implementation provides additional named
11653 predefined floating point types, then the names should end with
11654 @samp{Float} as in @samp{Long_Float}.
11655 @end cartouche
11656 Followed.
11657
11658 @findex Ada.Characters.Handling
11659 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
11660 @sp 1
11661 @cartouche
11662 If an implementation provides a localized definition of @code{Character}
11663 or @code{Wide_Character}, then the effects of the subprograms in
11664 @code{Characters.Handling} should reflect the localizations. See also
11665 3.5.2.
11666 @end cartouche
11667 Followed. GNAT provides no such localized definitions.
11668
11669 @cindex Bounded-length strings
11670 @unnumberedsec A.4.4(106): Bounded-Length String Handling
11671 @sp 1
11672 @cartouche
11673 Bounded string objects should not be implemented by implicit pointers
11674 and dynamic allocation.
11675 @end cartouche
11676 Followed. No implicit pointers or dynamic allocation are used.
11677
11678 @cindex Random number generation
11679 @unnumberedsec A.5.2(46-47): Random Number Generation
11680 @sp 1
11681 @cartouche
11682 Any storage associated with an object of type @code{Generator} should be
11683 reclaimed on exit from the scope of the object.
11684 @end cartouche
11685 Followed.
11686
11687 @sp 1
11688 @cartouche
11689 If the generator period is sufficiently long in relation to the number
11690 of distinct initiator values, then each possible value of
11691 @code{Initiator} passed to @code{Reset} should initiate a sequence of
11692 random numbers that does not, in a practical sense, overlap the sequence
11693 initiated by any other value. If this is not possible, then the mapping
11694 between initiator values and generator states should be a rapidly
11695 varying function of the initiator value.
11696 @end cartouche
11697 Followed. The generator period is sufficiently long for the first
11698 condition here to hold true.
11699
11700 @findex Get_Immediate
11701 @unnumberedsec A.10.7(23): @code{Get_Immediate}
11702 @sp 1
11703 @cartouche
11704 The @code{Get_Immediate} procedures should be implemented with
11705 unbuffered input. For a device such as a keyboard, input should be
11706 @dfn{available} if a key has already been typed, whereas for a disk
11707 file, input should always be available except at end of file. For a file
11708 associated with a keyboard-like device, any line-editing features of the
11709 underlying operating system should be disabled during the execution of
11710 @code{Get_Immediate}.
11711 @end cartouche
11712 Followed on all targets except VxWorks. For VxWorks, there is no way to
11713 provide this functionality that does not result in the input buffer being
11714 flushed before the @code{Get_Immediate} call. A special unit
11715 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
11716 this functionality.
11717
11718 @findex Export
11719 @unnumberedsec B.1(39-41): Pragma @code{Export}
11720 @sp 1
11721 @cartouche
11722 If an implementation supports pragma @code{Export} to a given language,
11723 then it should also allow the main subprogram to be written in that
11724 language. It should support some mechanism for invoking the elaboration
11725 of the Ada library units included in the system, and for invoking the
11726 finalization of the environment task. On typical systems, the
11727 recommended mechanism is to provide two subprograms whose link names are
11728 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
11729 elaboration code for library units. @code{adafinal} should contain the
11730 finalization code. These subprograms should have no effect the second
11731 and subsequent time they are called.
11732 @end cartouche
11733 Followed.
11734
11735 @sp 1
11736 @cartouche
11737 Automatic elaboration of pre-elaborated packages should be
11738 provided when pragma @code{Export} is supported.
11739 @end cartouche
11740 Followed when the main program is in Ada. If the main program is in a
11741 foreign language, then
11742 @code{adainit} must be called to elaborate pre-elaborated
11743 packages.
11744
11745 @sp 1
11746 @cartouche
11747 For each supported convention @var{L} other than @code{Intrinsic}, an
11748 implementation should support @code{Import} and @code{Export} pragmas
11749 for objects of @var{L}-compatible types and for subprograms, and pragma
11750 @code{Convention} for @var{L}-eligible types and for subprograms,
11751 presuming the other language has corresponding features. Pragma
11752 @code{Convention} need not be supported for scalar types.
11753 @end cartouche
11754 Followed.
11755
11756 @cindex Package @code{Interfaces}
11757 @findex Interfaces
11758 @unnumberedsec B.2(12-13): Package @code{Interfaces}
11759 @sp 1
11760 @cartouche
11761 For each implementation-defined convention identifier, there should be a
11762 child package of package Interfaces with the corresponding name. This
11763 package should contain any declarations that would be useful for
11764 interfacing to the language (implementation) represented by the
11765 convention. Any declarations useful for interfacing to any language on
11766 the given hardware architecture should be provided directly in
11767 @code{Interfaces}.
11768 @end cartouche
11769 Followed. An additional package not defined
11770 in the Ada Reference Manual is @code{Interfaces.CPP}, used
11771 for interfacing to C++.
11772
11773 @sp 1
11774 @cartouche
11775 An implementation supporting an interface to C, COBOL, or Fortran should
11776 provide the corresponding package or packages described in the following
11777 clauses.
11778 @end cartouche
11779 Followed. GNAT provides all the packages described in this section.
11780
11781 @cindex C, interfacing with
11782 @unnumberedsec B.3(63-71): Interfacing with C
11783 @sp 1
11784 @cartouche
11785 An implementation should support the following interface correspondences
11786 between Ada and C@.
11787 @end cartouche
11788 Followed.
11789
11790 @sp 1
11791 @cartouche
11792 An Ada procedure corresponds to a void-returning C function.
11793 @end cartouche
11794 Followed.
11795
11796 @sp 1
11797 @cartouche
11798 An Ada function corresponds to a non-void C function.
11799 @end cartouche
11800 Followed.
11801
11802 @sp 1
11803 @cartouche
11804 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
11805 function.
11806 @end cartouche
11807 Followed.
11808
11809 @sp 1
11810 @cartouche
11811 An Ada @code{in} parameter of an access-to-object type with designated
11812 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
11813 where @var{t} is the C type corresponding to the Ada type @var{T}.
11814 @end cartouche
11815 Followed.
11816
11817 @sp 1
11818 @cartouche
11819 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
11820 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
11821 argument to a C function, where @var{t} is the C type corresponding to
11822 the Ada type @var{T}. In the case of an elementary @code{out} or
11823 @code{in out} parameter, a pointer to a temporary copy is used to
11824 preserve by-copy semantics.
11825 @end cartouche
11826 Followed.
11827
11828 @sp 1
11829 @cartouche
11830 An Ada parameter of a record type @var{T}, of any mode, is passed as a
11831 @code{@var{t}*} argument to a C function, where @var{t} is the C
11832 structure corresponding to the Ada type @var{T}.
11833 @end cartouche
11834 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
11835 pragma, or Convention, or by explicitly specifying the mechanism for a given
11836 call using an extended import or export pragma.
11837
11838 @sp 1
11839 @cartouche
11840 An Ada parameter of an array type with component type @var{T}, of any
11841 mode, is passed as a @code{@var{t}*} argument to a C function, where
11842 @var{t} is the C type corresponding to the Ada type @var{T}.
11843 @end cartouche
11844 Followed.
11845
11846 @sp 1
11847 @cartouche
11848 An Ada parameter of an access-to-subprogram type is passed as a pointer
11849 to a C function whose prototype corresponds to the designated
11850 subprogram's specification.
11851 @end cartouche
11852 Followed.
11853
11854 @cindex COBOL, interfacing with
11855 @unnumberedsec B.4(95-98): Interfacing with COBOL
11856 @sp 1
11857 @cartouche
11858 An Ada implementation should support the following interface
11859 correspondences between Ada and COBOL@.
11860 @end cartouche
11861 Followed.
11862
11863 @sp 1
11864 @cartouche
11865 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
11866 the COBOL type corresponding to @var{T}.
11867 @end cartouche
11868 Followed.
11869
11870 @sp 1
11871 @cartouche
11872 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
11873 the corresponding COBOL type.
11874 @end cartouche
11875 Followed.
11876
11877 @sp 1
11878 @cartouche
11879 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
11880 COBOL type corresponding to the Ada parameter type; for scalars, a local
11881 copy is used if necessary to ensure by-copy semantics.
11882 @end cartouche
11883 Followed.
11884
11885 @cindex Fortran, interfacing with
11886 @unnumberedsec B.5(22-26): Interfacing with Fortran
11887 @sp 1
11888 @cartouche
11889 An Ada implementation should support the following interface
11890 correspondences between Ada and Fortran:
11891 @end cartouche
11892 Followed.
11893
11894 @sp 1
11895 @cartouche
11896 An Ada procedure corresponds to a Fortran subroutine.
11897 @end cartouche
11898 Followed.
11899
11900 @sp 1
11901 @cartouche
11902 An Ada function corresponds to a Fortran function.
11903 @end cartouche
11904 Followed.
11905
11906 @sp 1
11907 @cartouche
11908 An Ada parameter of an elementary, array, or record type @var{T} is
11909 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
11910 the Fortran type corresponding to the Ada type @var{T}, and where the
11911 INTENT attribute of the corresponding dummy argument matches the Ada
11912 formal parameter mode; the Fortran implementation's parameter passing
11913 conventions are used. For elementary types, a local copy is used if
11914 necessary to ensure by-copy semantics.
11915 @end cartouche
11916 Followed.
11917
11918 @sp 1
11919 @cartouche
11920 An Ada parameter of an access-to-subprogram type is passed as a
11921 reference to a Fortran procedure whose interface corresponds to the
11922 designated subprogram's specification.
11923 @end cartouche
11924 Followed.
11925
11926 @cindex Machine operations
11927 @unnumberedsec C.1(3-5): Access to Machine Operations
11928 @sp 1
11929 @cartouche
11930 The machine code or intrinsic support should allow access to all
11931 operations normally available to assembly language programmers for the
11932 target environment, including privileged instructions, if any.
11933 @end cartouche
11934 Followed.
11935
11936 @sp 1
11937 @cartouche
11938 The interfacing pragmas (see Annex B) should support interface to
11939 assembler; the default assembler should be associated with the
11940 convention identifier @code{Assembler}.
11941 @end cartouche
11942 Followed.
11943
11944 @sp 1
11945 @cartouche
11946 If an entity is exported to assembly language, then the implementation
11947 should allocate it at an addressable location, and should ensure that it
11948 is retained by the linking process, even if not otherwise referenced
11949 from the Ada code. The implementation should assume that any call to a
11950 machine code or assembler subprogram is allowed to read or update every
11951 object that is specified as exported.
11952 @end cartouche
11953 Followed.
11954
11955 @unnumberedsec C.1(10-16): Access to Machine Operations
11956 @sp 1
11957 @cartouche
11958 The implementation should ensure that little or no overhead is
11959 associated with calling intrinsic and machine-code subprograms.
11960 @end cartouche
11961 Followed for both intrinsics and machine-code subprograms.
11962
11963 @sp 1
11964 @cartouche
11965 It is recommended that intrinsic subprograms be provided for convenient
11966 access to any machine operations that provide special capabilities or
11967 efficiency and that are not otherwise available through the language
11968 constructs.
11969 @end cartouche
11970 Followed. A full set of machine operation intrinsic subprograms is provided.
11971
11972 @sp 1
11973 @cartouche
11974 Atomic read-modify-write operations---e.g.@:, test and set, compare and
11975 swap, decrement and test, enqueue/dequeue.
11976 @end cartouche
11977 Followed on any target supporting such operations.
11978
11979 @sp 1
11980 @cartouche
11981 Standard numeric functions---e.g.@:, sin, log.
11982 @end cartouche
11983 Followed on any target supporting such operations.
11984
11985 @sp 1
11986 @cartouche
11987 String manipulation operations---e.g.@:, translate and test.
11988 @end cartouche
11989 Followed on any target supporting such operations.
11990
11991 @sp 1
11992 @cartouche
11993 Vector operations---e.g.@:, compare vector against thresholds.
11994 @end cartouche
11995 Followed on any target supporting such operations.
11996
11997 @sp 1
11998 @cartouche
11999 Direct operations on I/O ports.
12000 @end cartouche
12001 Followed on any target supporting such operations.
12002
12003 @cindex Interrupt support
12004 @unnumberedsec C.3(28): Interrupt Support
12005 @sp 1
12006 @cartouche
12007 If the @code{Ceiling_Locking} policy is not in effect, the
12008 implementation should provide means for the application to specify which
12009 interrupts are to be blocked during protected actions, if the underlying
12010 system allows for a finer-grain control of interrupt blocking.
12011 @end cartouche
12012 Followed. The underlying system does not allow for finer-grain control
12013 of interrupt blocking.
12014
12015 @cindex Protected procedure handlers
12016 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
12017 @sp 1
12018 @cartouche
12019 Whenever possible, the implementation should allow interrupt handlers to
12020 be called directly by the hardware.
12021 @end cartouche
12022 Followed on any target where the underlying operating system permits
12023 such direct calls.
12024
12025 @sp 1
12026 @cartouche
12027 Whenever practical, violations of any
12028 implementation-defined restrictions should be detected before run time.
12029 @end cartouche
12030 Followed. Compile time warnings are given when possible.
12031
12032 @cindex Package @code{Interrupts}
12033 @findex Interrupts
12034 @unnumberedsec C.3.2(25): Package @code{Interrupts}
12035
12036 @sp 1
12037 @cartouche
12038 If implementation-defined forms of interrupt handler procedures are
12039 supported, such as protected procedures with parameters, then for each
12040 such form of a handler, a type analogous to @code{Parameterless_Handler}
12041 should be specified in a child package of @code{Interrupts}, with the
12042 same operations as in the predefined package Interrupts.
12043 @end cartouche
12044 Followed.
12045
12046 @cindex Pre-elaboration requirements
12047 @unnumberedsec C.4(14): Pre-elaboration Requirements
12048 @sp 1
12049 @cartouche
12050 It is recommended that pre-elaborated packages be implemented in such a
12051 way that there should be little or no code executed at run time for the
12052 elaboration of entities not already covered by the Implementation
12053 Requirements.
12054 @end cartouche
12055 Followed. Executable code is generated in some cases, e.g.@: loops
12056 to initialize large arrays.
12057
12058 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
12059 @sp 1
12060 @cartouche
12061 If the pragma applies to an entity, then the implementation should
12062 reduce the amount of storage used for storing names associated with that
12063 entity.
12064 @end cartouche
12065 Followed.
12066
12067 @cindex Package @code{Task_Attributes}
12068 @findex Task_Attributes
12069 @unnumberedsec C.7.2(30): The Package Task_Attributes
12070 @sp 1
12071 @cartouche
12072 Some implementations are targeted to domains in which memory use at run
12073 time must be completely deterministic. For such implementations, it is
12074 recommended that the storage for task attributes will be pre-allocated
12075 statically and not from the heap. This can be accomplished by either
12076 placing restrictions on the number and the size of the task's
12077 attributes, or by using the pre-allocated storage for the first @var{N}
12078 attribute objects, and the heap for the others. In the latter case,
12079 @var{N} should be documented.
12080 @end cartouche
12081 Not followed. This implementation is not targeted to such a domain.
12082
12083 @cindex Locking Policies
12084 @unnumberedsec D.3(17): Locking Policies
12085
12086 @sp 1
12087 @cartouche
12088 The implementation should use names that end with @samp{_Locking} for
12089 locking policies defined by the implementation.
12090 @end cartouche
12091 Followed. Two implementation-defined locking policies are defined,
12092 whose names (@code{Inheritance_Locking} and
12093 @code{Concurrent_Readers_Locking}) follow this suggestion.
12094
12095 @cindex Entry queuing policies
12096 @unnumberedsec D.4(16): Entry Queuing Policies
12097 @sp 1
12098 @cartouche
12099 Names that end with @samp{_Queuing} should be used
12100 for all implementation-defined queuing policies.
12101 @end cartouche
12102 Followed. No such implementation-defined queuing policies exist.
12103
12104 @cindex Preemptive abort
12105 @unnumberedsec D.6(9-10): Preemptive Abort
12106 @sp 1
12107 @cartouche
12108 Even though the @code{abort_statement} is included in the list of
12109 potentially blocking operations (see 9.5.1), it is recommended that this
12110 statement be implemented in a way that never requires the task executing
12111 the @code{abort_statement} to block.
12112 @end cartouche
12113 Followed.
12114
12115 @sp 1
12116 @cartouche
12117 On a multi-processor, the delay associated with aborting a task on
12118 another processor should be bounded; the implementation should use
12119 periodic polling, if necessary, to achieve this.
12120 @end cartouche
12121 Followed.
12122
12123 @cindex Tasking restrictions
12124 @unnumberedsec D.7(21): Tasking Restrictions
12125 @sp 1
12126 @cartouche
12127 When feasible, the implementation should take advantage of the specified
12128 restrictions to produce a more efficient implementation.
12129 @end cartouche
12130 GNAT currently takes advantage of these restrictions by providing an optimized
12131 run time when the Ravenscar profile and the GNAT restricted run time set
12132 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
12133 pragma @code{Profile (Restricted)} for more details.
12134
12135 @cindex Time, monotonic
12136 @unnumberedsec D.8(47-49): Monotonic Time
12137 @sp 1
12138 @cartouche
12139 When appropriate, implementations should provide configuration
12140 mechanisms to change the value of @code{Tick}.
12141 @end cartouche
12142 Such configuration mechanisms are not appropriate to this implementation
12143 and are thus not supported.
12144
12145 @sp 1
12146 @cartouche
12147 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
12148 be implemented as transformations of the same time base.
12149 @end cartouche
12150 Followed.
12151
12152 @sp 1
12153 @cartouche
12154 It is recommended that the @dfn{best} time base which exists in
12155 the underlying system be available to the application through
12156 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
12157 @end cartouche
12158 Followed.
12159
12160 @cindex Partition communication subsystem
12161 @cindex PCS
12162 @unnumberedsec E.5(28-29): Partition Communication Subsystem
12163 @sp 1
12164 @cartouche
12165 Whenever possible, the PCS on the called partition should allow for
12166 multiple tasks to call the RPC-receiver with different messages and
12167 should allow them to block until the corresponding subprogram body
12168 returns.
12169 @end cartouche
12170 Followed by GLADE, a separately supplied PCS that can be used with
12171 GNAT.
12172
12173 @sp 1
12174 @cartouche
12175 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
12176 should raise @code{Storage_Error} if it runs out of space trying to
12177 write the @code{Item} into the stream.
12178 @end cartouche
12179 Followed by GLADE, a separately supplied PCS that can be used with
12180 GNAT@.
12181
12182 @cindex COBOL support
12183 @unnumberedsec F(7): COBOL Support
12184 @sp 1
12185 @cartouche
12186 If COBOL (respectively, C) is widely supported in the target
12187 environment, implementations supporting the Information Systems Annex
12188 should provide the child package @code{Interfaces.COBOL} (respectively,
12189 @code{Interfaces.C}) specified in Annex B and should support a
12190 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
12191 pragmas (see Annex B), thus allowing Ada programs to interface with
12192 programs written in that language.
12193 @end cartouche
12194 Followed.
12195
12196 @cindex Decimal radix support
12197 @unnumberedsec F.1(2): Decimal Radix Support
12198 @sp 1
12199 @cartouche
12200 Packed decimal should be used as the internal representation for objects
12201 of subtype @var{S} when @var{S}'Machine_Radix = 10.
12202 @end cartouche
12203 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
12204 representations.
12205
12206 @cindex Numerics
12207 @unnumberedsec G: Numerics
12208 @sp 2
12209 @cartouche
12210 If Fortran (respectively, C) is widely supported in the target
12211 environment, implementations supporting the Numerics Annex
12212 should provide the child package @code{Interfaces.Fortran} (respectively,
12213 @code{Interfaces.C}) specified in Annex B and should support a
12214 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
12215 pragmas (see Annex B), thus allowing Ada programs to interface with
12216 programs written in that language.
12217 @end cartouche
12218 Followed.
12219
12220 @cindex Complex types
12221 @unnumberedsec G.1.1(56-58): Complex Types
12222 @sp 2
12223 @cartouche
12224 Because the usual mathematical meaning of multiplication of a complex
12225 operand and a real operand is that of the scaling of both components of
12226 the former by the latter, an implementation should not perform this
12227 operation by first promoting the real operand to complex type and then
12228 performing a full complex multiplication. In systems that, in the
12229 future, support an Ada binding to IEC 559:1989, the latter technique
12230 will not generate the required result when one of the components of the
12231 complex operand is infinite. (Explicit multiplication of the infinite
12232 component by the zero component obtained during promotion yields a NaN
12233 that propagates into the final result.) Analogous advice applies in the
12234 case of multiplication of a complex operand and a pure-imaginary
12235 operand, and in the case of division of a complex operand by a real or
12236 pure-imaginary operand.
12237 @end cartouche
12238 Not followed.
12239
12240 @sp 1
12241 @cartouche
12242 Similarly, because the usual mathematical meaning of addition of a
12243 complex operand and a real operand is that the imaginary operand remains
12244 unchanged, an implementation should not perform this operation by first
12245 promoting the real operand to complex type and then performing a full
12246 complex addition. In implementations in which the @code{Signed_Zeros}
12247 attribute of the component type is @code{True} (and which therefore
12248 conform to IEC 559:1989 in regard to the handling of the sign of zero in
12249 predefined arithmetic operations), the latter technique will not
12250 generate the required result when the imaginary component of the complex
12251 operand is a negatively signed zero. (Explicit addition of the negative
12252 zero to the zero obtained during promotion yields a positive zero.)
12253 Analogous advice applies in the case of addition of a complex operand
12254 and a pure-imaginary operand, and in the case of subtraction of a
12255 complex operand and a real or pure-imaginary operand.
12256 @end cartouche
12257 Not followed.
12258
12259 @sp 1
12260 @cartouche
12261 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
12262 attempt to provide a rational treatment of the signs of zero results and
12263 result components. As one example, the result of the @code{Argument}
12264 function should have the sign of the imaginary component of the
12265 parameter @code{X} when the point represented by that parameter lies on
12266 the positive real axis; as another, the sign of the imaginary component
12267 of the @code{Compose_From_Polar} function should be the same as
12268 (respectively, the opposite of) that of the @code{Argument} parameter when that
12269 parameter has a value of zero and the @code{Modulus} parameter has a
12270 nonnegative (respectively, negative) value.
12271 @end cartouche
12272 Followed.
12273
12274 @cindex Complex elementary functions
12275 @unnumberedsec G.1.2(49): Complex Elementary Functions
12276 @sp 1
12277 @cartouche
12278 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
12279 @code{True} should attempt to provide a rational treatment of the signs
12280 of zero results and result components. For example, many of the complex
12281 elementary functions have components that are odd functions of one of
12282 the parameter components; in these cases, the result component should
12283 have the sign of the parameter component at the origin. Other complex
12284 elementary functions have zero components whose sign is opposite that of
12285 a parameter component at the origin, or is always positive or always
12286 negative.
12287 @end cartouche
12288 Followed.
12289
12290 @cindex Accuracy requirements
12291 @unnumberedsec G.2.4(19): Accuracy Requirements
12292 @sp 1
12293 @cartouche
12294 The versions of the forward trigonometric functions without a
12295 @code{Cycle} parameter should not be implemented by calling the
12296 corresponding version with a @code{Cycle} parameter of
12297 @code{2.0*Numerics.Pi}, since this will not provide the required
12298 accuracy in some portions of the domain. For the same reason, the
12299 version of @code{Log} without a @code{Base} parameter should not be
12300 implemented by calling the corresponding version with a @code{Base}
12301 parameter of @code{Numerics.e}.
12302 @end cartouche
12303 Followed.
12304
12305 @cindex Complex arithmetic accuracy
12306 @cindex Accuracy, complex arithmetic
12307 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
12308
12309 @sp 1
12310 @cartouche
12311 The version of the @code{Compose_From_Polar} function without a
12312 @code{Cycle} parameter should not be implemented by calling the
12313 corresponding version with a @code{Cycle} parameter of
12314 @code{2.0*Numerics.Pi}, since this will not provide the required
12315 accuracy in some portions of the domain.
12316 @end cartouche
12317 Followed.
12318
12319 @cindex Sequential elaboration policy
12320 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
12321
12322 @sp 1
12323 @cartouche
12324 If the partition elaboration policy is @code{Sequential} and the
12325 Environment task becomes permanently blocked during elaboration then the
12326 partition is deadlocked and it is recommended that the partition be
12327 immediately terminated.
12328 @end cartouche
12329 Not followed.
12330
12331 @c -----------------------------------------
12332 @node Implementation Defined Characteristics
12333 @chapter Implementation Defined Characteristics
12334
12335 @noindent
12336 In addition to the implementation dependent pragmas and attributes, and the
12337 implementation advice, there are a number of other Ada features that are
12338 potentially implementation dependent and are designated as
12339 implementation-defined. These are mentioned throughout the Ada Reference
12340 Manual, and are summarized in Annex M@.
12341
12342 A requirement for conforming Ada compilers is that they provide
12343 documentation describing how the implementation deals with each of these
12344 issues. In this chapter you will find each point in Annex M listed,
12345 followed by a description of how GNAT
12346 handles the implementation dependence.
12347
12348 You can use this chapter as a guide to minimizing implementation
12349 dependent features in your programs if portability to other compilers
12350 and other operating systems is an important consideration. The numbers
12351 in each entry below correspond to the paragraph numbers in the Ada
12352 Reference Manual.
12353
12354
12355 @itemize @bullet
12356 @sp 1
12357 @item
12358 @cartouche
12359 @noindent
12360 Whether or not each recommendation given in Implementation
12361 Advice is followed. See 1.1.2(37).
12362 @end cartouche
12363 @noindent
12364 @xref{Implementation Advice}.
12365
12366
12367 @sp 1
12368 @item
12369 @cartouche
12370 @noindent
12371 Capacity limitations of the implementation. See 1.1.3(3).
12372 @end cartouche
12373 @noindent
12374 The complexity of programs that can be processed is limited only by the
12375 total amount of available virtual memory, and disk space for the
12376 generated object files.
12377
12378
12379 @sp 1
12380 @item
12381 @cartouche
12382 @noindent
12383 Variations from the standard that are impractical to avoid
12384 given the implementation's execution environment. See 1.1.3(6).
12385 @end cartouche
12386 @noindent
12387 There are no variations from the standard.
12388
12389
12390 @sp 1
12391 @item
12392 @cartouche
12393 @noindent
12394 Which @code{code_statement}s cause external
12395 interactions. See 1.1.3(10).
12396 @end cartouche
12397 @noindent
12398 Any @code{code_statement} can potentially cause external interactions.
12399
12400 @sp 1
12401 @item
12402 @cartouche
12403 @noindent
12404 The coded representation for the text of an Ada
12405 program. See 2.1(4).
12406 @end cartouche
12407 @noindent
12408 See separate section on source representation.
12409
12410
12411 @sp 1
12412 @item
12413 @cartouche
12414 @noindent
12415 The control functions allowed in comments. See 2.1(14).
12416 @end cartouche
12417 @noindent
12418 See separate section on source representation.
12419
12420 @sp 1
12421 @item
12422 @cartouche
12423 @noindent
12424 The representation for an end of line. See 2.2(2).
12425 @end cartouche
12426 @noindent
12427 See separate section on source representation.
12428
12429 @sp 1
12430 @item
12431 @cartouche
12432 @noindent
12433 Maximum supported line length and lexical element
12434 length. See 2.2(15).
12435 @end cartouche
12436 @noindent
12437 The maximum line length is 255 characters and the maximum length of
12438 a lexical element is also 255 characters. This is the default setting
12439 if not overridden by the use of compiler switch @option{-gnaty} (which
12440 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
12441 line length to be specified to be any value up to 32767. The maximum
12442 length of a lexical element is the same as the maximum line length.
12443
12444 @sp 1
12445 @item
12446 @cartouche
12447 @noindent
12448 Implementation defined pragmas. See 2.8(14).
12449 @end cartouche
12450 @noindent
12451
12452 @xref{Implementation Defined Pragmas}.
12453
12454 @sp 1
12455 @item
12456 @cartouche
12457 @noindent
12458 Effect of pragma @code{Optimize}. See 2.8(27).
12459 @end cartouche
12460 @noindent
12461 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
12462 parameter, checks that the optimization flag is set, and aborts if it is
12463 not.
12464
12465 @sp 1
12466 @item
12467 @cartouche
12468 @noindent
12469 The sequence of characters of the value returned by
12470 @code{@var{S}'Image} when some of the graphic characters of
12471 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
12472 3.5(37).
12473 @end cartouche
12474 @noindent
12475 The sequence of characters is as defined by the wide character encoding
12476 method used for the source. See section on source representation for
12477 further details.
12478
12479 @sp 1
12480 @item
12481 @cartouche
12482 @noindent
12483 The predefined integer types declared in
12484 @code{Standard}. See 3.5.4(25).
12485 @end cartouche
12486 @noindent
12487 @table @code
12488 @item Short_Short_Integer
12489 8 bit signed
12490 @item Short_Integer
12491 (Short) 16 bit signed
12492 @item Integer
12493 32 bit signed
12494 @item Long_Integer
12495 64 bit signed (on most 64 bit targets, depending on the C definition of long).
12496 32 bit signed (all other targets)
12497 @item Long_Long_Integer
12498 64 bit signed
12499 @end table
12500
12501 @sp 1
12502 @item
12503 @cartouche
12504 @noindent
12505 Any nonstandard integer types and the operators defined
12506 for them. See 3.5.4(26).
12507 @end cartouche
12508 @noindent
12509 There are no nonstandard integer types.
12510
12511 @sp 1
12512 @item
12513 @cartouche
12514 @noindent
12515 Any nonstandard real types and the operators defined for
12516 them. See 3.5.6(8).
12517 @end cartouche
12518 @noindent
12519 There are no nonstandard real types.
12520
12521 @sp 1
12522 @item
12523 @cartouche
12524 @noindent
12525 What combinations of requested decimal precision and range
12526 are supported for floating point types. See 3.5.7(7).
12527 @end cartouche
12528 @noindent
12529 The precision and range is as defined by the IEEE standard.
12530
12531 @sp 1
12532 @item
12533 @cartouche
12534 @noindent
12535 The predefined floating point types declared in
12536 @code{Standard}. See 3.5.7(16).
12537 @end cartouche
12538 @noindent
12539 @table @code
12540 @item Short_Float
12541 32 bit IEEE short
12542 @item Float
12543 (Short) 32 bit IEEE short
12544 @item Long_Float
12545 64 bit IEEE long
12546 @item Long_Long_Float
12547 64 bit IEEE long (80 bit IEEE long on x86 processors)
12548 @end table
12549
12550 @sp 1
12551 @item
12552 @cartouche
12553 @noindent
12554 The small of an ordinary fixed point type. See 3.5.9(8).
12555 @end cartouche
12556 @noindent
12557 @code{Fine_Delta} is 2**(@minus{}63)
12558
12559 @sp 1
12560 @item
12561 @cartouche
12562 @noindent
12563 What combinations of small, range, and digits are
12564 supported for fixed point types. See 3.5.9(10).
12565 @end cartouche
12566 @noindent
12567 Any combinations are permitted that do not result in a small less than
12568 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
12569 If the mantissa is larger than 53 bits on machines where Long_Long_Float
12570 is 64 bits (true of all architectures except ia32), then the output from
12571 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
12572 is because floating-point conversions are used to convert fixed point.
12573
12574 @sp 1
12575 @item
12576 @cartouche
12577 @noindent
12578 The result of @code{Tags.Expanded_Name} for types declared
12579 within an unnamed @code{block_statement}. See 3.9(10).
12580 @end cartouche
12581 @noindent
12582 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
12583 decimal integer are allocated.
12584
12585 @sp 1
12586 @item
12587 @cartouche
12588 @noindent
12589 Implementation-defined attributes. See 4.1.4(12).
12590 @end cartouche
12591 @noindent
12592 @xref{Implementation Defined Attributes}.
12593
12594 @sp 1
12595 @item
12596 @cartouche
12597 @noindent
12598 Any implementation-defined time types. See 9.6(6).
12599 @end cartouche
12600 @noindent
12601 There are no implementation-defined time types.
12602
12603 @sp 1
12604 @item
12605 @cartouche
12606 @noindent
12607 The time base associated with relative delays.
12608 @end cartouche
12609 @noindent
12610 See 9.6(20). The time base used is that provided by the C library
12611 function @code{gettimeofday}.
12612
12613 @sp 1
12614 @item
12615 @cartouche
12616 @noindent
12617 The time base of the type @code{Calendar.Time}. See
12618 9.6(23).
12619 @end cartouche
12620 @noindent
12621 The time base used is that provided by the C library function
12622 @code{gettimeofday}.
12623
12624 @sp 1
12625 @item
12626 @cartouche
12627 @noindent
12628 The time zone used for package @code{Calendar}
12629 operations. See 9.6(24).
12630 @end cartouche
12631 @noindent
12632 The time zone used by package @code{Calendar} is the current system time zone
12633 setting for local time, as accessed by the C library function
12634 @code{localtime}.
12635
12636 @sp 1
12637 @item
12638 @cartouche
12639 @noindent
12640 Any limit on @code{delay_until_statements} of
12641 @code{select_statements}. See 9.6(29).
12642 @end cartouche
12643 @noindent
12644 There are no such limits.
12645
12646 @sp 1
12647 @item
12648 @cartouche
12649 @noindent
12650 Whether or not two non-overlapping parts of a composite
12651 object are independently addressable, in the case where packing, record
12652 layout, or @code{Component_Size} is specified for the object. See
12653 9.10(1).
12654 @end cartouche
12655 @noindent
12656 Separate components are independently addressable if they do not share
12657 overlapping storage units.
12658
12659 @sp 1
12660 @item
12661 @cartouche
12662 @noindent
12663 The representation for a compilation. See 10.1(2).
12664 @end cartouche
12665 @noindent
12666 A compilation is represented by a sequence of files presented to the
12667 compiler in a single invocation of the @command{gcc} command.
12668
12669 @sp 1
12670 @item
12671 @cartouche
12672 @noindent
12673 Any restrictions on compilations that contain multiple
12674 compilation_units. See 10.1(4).
12675 @end cartouche
12676 @noindent
12677 No single file can contain more than one compilation unit, but any
12678 sequence of files can be presented to the compiler as a single
12679 compilation.
12680
12681 @sp 1
12682 @item
12683 @cartouche
12684 @noindent
12685 The mechanisms for creating an environment and for adding
12686 and replacing compilation units. See 10.1.4(3).
12687 @end cartouche
12688 @noindent
12689 See separate section on compilation model.
12690
12691 @sp 1
12692 @item
12693 @cartouche
12694 @noindent
12695 The manner of explicitly assigning library units to a
12696 partition. See 10.2(2).
12697 @end cartouche
12698 @noindent
12699 If a unit contains an Ada main program, then the Ada units for the partition
12700 are determined by recursive application of the rules in the Ada Reference
12701 Manual section 10.2(2-6). In other words, the Ada units will be those that
12702 are needed by the main program, and then this definition of need is applied
12703 recursively to those units, and the partition contains the transitive
12704 closure determined by this relationship. In short, all the necessary units
12705 are included, with no need to explicitly specify the list. If additional
12706 units are required, e.g.@: by foreign language units, then all units must be
12707 mentioned in the context clause of one of the needed Ada units.
12708
12709 If the partition contains no main program, or if the main program is in
12710 a language other than Ada, then GNAT
12711 provides the binder options @option{-z} and @option{-n} respectively, and in
12712 this case a list of units can be explicitly supplied to the binder for
12713 inclusion in the partition (all units needed by these units will also
12714 be included automatically). For full details on the use of these
12715 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
12716 @value{EDITION} User's Guide}.
12717
12718 @sp 1
12719 @item
12720 @cartouche
12721 @noindent
12722 The implementation-defined means, if any, of specifying
12723 which compilation units are needed by a given compilation unit. See
12724 10.2(2).
12725 @end cartouche
12726 @noindent
12727 The units needed by a given compilation unit are as defined in
12728 the Ada Reference Manual section 10.2(2-6). There are no
12729 implementation-defined pragmas or other implementation-defined
12730 means for specifying needed units.
12731
12732 @sp 1
12733 @item
12734 @cartouche
12735 @noindent
12736 The manner of designating the main subprogram of a
12737 partition. See 10.2(7).
12738 @end cartouche
12739 @noindent
12740 The main program is designated by providing the name of the
12741 corresponding @file{ALI} file as the input parameter to the binder.
12742
12743 @sp 1
12744 @item
12745 @cartouche
12746 @noindent
12747 The order of elaboration of @code{library_items}. See
12748 10.2(18).
12749 @end cartouche
12750 @noindent
12751 The first constraint on ordering is that it meets the requirements of
12752 Chapter 10 of the Ada Reference Manual. This still leaves some
12753 implementation dependent choices, which are resolved by first
12754 elaborating bodies as early as possible (i.e., in preference to specs
12755 where there is a choice), and second by evaluating the immediate with
12756 clauses of a unit to determine the probably best choice, and
12757 third by elaborating in alphabetical order of unit names
12758 where a choice still remains.
12759
12760 @sp 1
12761 @item
12762 @cartouche
12763 @noindent
12764 Parameter passing and function return for the main
12765 subprogram. See 10.2(21).
12766 @end cartouche
12767 @noindent
12768 The main program has no parameters. It may be a procedure, or a function
12769 returning an integer type. In the latter case, the returned integer
12770 value is the return code of the program (overriding any value that
12771 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
12772
12773 @sp 1
12774 @item
12775 @cartouche
12776 @noindent
12777 The mechanisms for building and running partitions. See
12778 10.2(24).
12779 @end cartouche
12780 @noindent
12781 GNAT itself supports programs with only a single partition. The GNATDIST
12782 tool provided with the GLADE package (which also includes an implementation
12783 of the PCS) provides a completely flexible method for building and running
12784 programs consisting of multiple partitions. See the separate GLADE manual
12785 for details.
12786
12787 @sp 1
12788 @item
12789 @cartouche
12790 @noindent
12791 The details of program execution, including program
12792 termination. See 10.2(25).
12793 @end cartouche
12794 @noindent
12795 See separate section on compilation model.
12796
12797 @sp 1
12798 @item
12799 @cartouche
12800 @noindent
12801 The semantics of any non-active partitions supported by the
12802 implementation. See 10.2(28).
12803 @end cartouche
12804 @noindent
12805 Passive partitions are supported on targets where shared memory is
12806 provided by the operating system. See the GLADE reference manual for
12807 further details.
12808
12809 @sp 1
12810 @item
12811 @cartouche
12812 @noindent
12813 The information returned by @code{Exception_Message}. See
12814 11.4.1(10).
12815 @end cartouche
12816 @noindent
12817 Exception message returns the null string unless a specific message has
12818 been passed by the program.
12819
12820 @sp 1
12821 @item
12822 @cartouche
12823 @noindent
12824 The result of @code{Exceptions.Exception_Name} for types
12825 declared within an unnamed @code{block_statement}. See 11.4.1(12).
12826 @end cartouche
12827 @noindent
12828 Blocks have implementation defined names of the form @code{B@var{nnn}}
12829 where @var{nnn} is an integer.
12830
12831 @sp 1
12832 @item
12833 @cartouche
12834 @noindent
12835 The information returned by
12836 @code{Exception_Information}. See 11.4.1(13).
12837 @end cartouche
12838 @noindent
12839 @code{Exception_Information} returns a string in the following format:
12840
12841 @smallexample
12842 @emph{Exception_Name:} nnnnn
12843 @emph{Message:} mmmmm
12844 @emph{PID:} ppp
12845 @emph{Load address:} 0xhhhh
12846 @emph{Call stack traceback locations:}
12847 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
12848 @end smallexample
12849
12850 @noindent
12851 where
12852
12853 @itemize @bullet
12854 @item
12855 @code{nnnn} is the fully qualified name of the exception in all upper
12856 case letters. This line is always present.
12857
12858 @item
12859 @code{mmmm} is the message (this line present only if message is non-null)
12860
12861 @item
12862 @code{ppp} is the Process Id value as a decimal integer (this line is
12863 present only if the Process Id is nonzero). Currently we are
12864 not making use of this field.
12865
12866 @item
12867 The Load address line, the Call stack traceback locations line and the
12868 following values are present only if at least one traceback location was
12869 recorded. The Load address indicates the address at which the main executable
12870 was loaded; this line may not be present if operating system hasn't relocated
12871 the main executable. The values are given in C style format, with lower case
12872 letters for a-f, and only as many digits present as are necessary.
12873 @end itemize
12874
12875 @noindent
12876 The line terminator sequence at the end of each line, including
12877 the last line is a single @code{LF} character (@code{16#0A#}).
12878
12879 @sp 1
12880 @item
12881 @cartouche
12882 @noindent
12883 Implementation-defined check names. See 11.5(27).
12884 @end cartouche
12885 @noindent
12886 The implementation defined check name Alignment_Check controls checking of
12887 address clause values for proper alignment (that is, the address supplied
12888 must be consistent with the alignment of the type).
12889
12890 The implementation defined check name Predicate_Check controls whether
12891 predicate checks are generated.
12892
12893 The implementation defined check name Validity_Check controls whether
12894 validity checks are generated.
12895
12896 In addition, a user program can add implementation-defined check names
12897 by means of the pragma Check_Name.
12898
12899 @sp 1
12900 @item
12901 @cartouche
12902 @noindent
12903 The interpretation of each aspect of representation. See
12904 13.1(20).
12905 @end cartouche
12906 @noindent
12907 See separate section on data representations.
12908
12909 @sp 1
12910 @item
12911 @cartouche
12912 @noindent
12913 Any restrictions placed upon representation items. See
12914 13.1(20).
12915 @end cartouche
12916 @noindent
12917 See separate section on data representations.
12918
12919 @sp 1
12920 @item
12921 @cartouche
12922 @noindent
12923 The meaning of @code{Size} for indefinite subtypes. See
12924 13.3(48).
12925 @end cartouche
12926 @noindent
12927 Size for an indefinite subtype is the maximum possible size, except that
12928 for the case of a subprogram parameter, the size of the parameter object
12929 is the actual size.
12930
12931 @sp 1
12932 @item
12933 @cartouche
12934 @noindent
12935 The default external representation for a type tag. See
12936 13.3(75).
12937 @end cartouche
12938 @noindent
12939 The default external representation for a type tag is the fully expanded
12940 name of the type in upper case letters.
12941
12942 @sp 1
12943 @item
12944 @cartouche
12945 @noindent
12946 What determines whether a compilation unit is the same in
12947 two different partitions. See 13.3(76).
12948 @end cartouche
12949 @noindent
12950 A compilation unit is the same in two different partitions if and only
12951 if it derives from the same source file.
12952
12953 @sp 1
12954 @item
12955 @cartouche
12956 @noindent
12957 Implementation-defined components. See 13.5.1(15).
12958 @end cartouche
12959 @noindent
12960 The only implementation defined component is the tag for a tagged type,
12961 which contains a pointer to the dispatching table.
12962
12963 @sp 1
12964 @item
12965 @cartouche
12966 @noindent
12967 If @code{Word_Size} = @code{Storage_Unit}, the default bit
12968 ordering. See 13.5.3(5).
12969 @end cartouche
12970 @noindent
12971 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
12972 implementation, so no non-default bit ordering is supported. The default
12973 bit ordering corresponds to the natural endianness of the target architecture.
12974
12975 @sp 1
12976 @item
12977 @cartouche
12978 @noindent
12979 The contents of the visible part of package @code{System}
12980 and its language-defined children. See 13.7(2).
12981 @end cartouche
12982 @noindent
12983 See the definition of these packages in files @file{system.ads} and
12984 @file{s-stoele.ads}.
12985
12986 @sp 1
12987 @item
12988 @cartouche
12989 @noindent
12990 The contents of the visible part of package
12991 @code{System.Machine_Code}, and the meaning of
12992 @code{code_statements}. See 13.8(7).
12993 @end cartouche
12994 @noindent
12995 See the definition and documentation in file @file{s-maccod.ads}.
12996
12997 @sp 1
12998 @item
12999 @cartouche
13000 @noindent
13001 The effect of unchecked conversion. See 13.9(11).
13002 @end cartouche
13003 @noindent
13004 Unchecked conversion between types of the same size
13005 results in an uninterpreted transmission of the bits from one type
13006 to the other. If the types are of unequal sizes, then in the case of
13007 discrete types, a shorter source is first zero or sign extended as
13008 necessary, and a shorter target is simply truncated on the left.
13009 For all non-discrete types, the source is first copied if necessary
13010 to ensure that the alignment requirements of the target are met, then
13011 a pointer is constructed to the source value, and the result is obtained
13012 by dereferencing this pointer after converting it to be a pointer to the
13013 target type. Unchecked conversions where the target subtype is an
13014 unconstrained array are not permitted. If the target alignment is
13015 greater than the source alignment, then a copy of the result is
13016 made with appropriate alignment
13017
13018 @sp 1
13019 @item
13020 @cartouche
13021 @noindent
13022 The semantics of operations on invalid representations.
13023 See 13.9.2(10-11).
13024 @end cartouche
13025 @noindent
13026 For assignments and other operations where the use of invalid values cannot
13027 result in erroneous behavior, the compiler ignores the possibility of invalid
13028 values. An exception is raised at the point where an invalid value would
13029 result in erroneous behavior. For example executing:
13030
13031 @smallexample @c ada
13032 procedure invalidvals is
13033 X : Integer := -1;
13034 Y : Natural range 1 .. 10;
13035 for Y'Address use X'Address;
13036 Z : Natural range 1 .. 10;
13037 A : array (Natural range 1 .. 10) of Integer;
13038 begin
13039 Z := Y; -- no exception
13040 A (Z) := 3; -- exception raised;
13041 end;
13042 @end smallexample
13043
13044 @noindent
13045 As indicated, an exception is raised on the array assignment, but not
13046 on the simple assignment of the invalid negative value from Y to Z.
13047
13048 @sp 1
13049 @item
13050 @cartouche
13051 @noindent
13052 The manner of choosing a storage pool for an access type
13053 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
13054 @end cartouche
13055 @noindent
13056 There are 3 different standard pools used by the compiler when
13057 @code{Storage_Pool} is not specified depending whether the type is local
13058 to a subprogram or defined at the library level and whether
13059 @code{Storage_Size}is specified or not. See documentation in the runtime
13060 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
13061 @code{System.Pool_Local} in files @file{s-poosiz.ads},
13062 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
13063 default pools used.
13064
13065 @sp 1
13066 @item
13067 @cartouche
13068 @noindent
13069 Whether or not the implementation provides user-accessible
13070 names for the standard pool type(s). See 13.11(17).
13071 @end cartouche
13072 @noindent
13073
13074 See documentation in the sources of the run time mentioned in the previous
13075 paragraph. All these pools are accessible by means of @code{with}'ing
13076 these units.
13077
13078 @sp 1
13079 @item
13080 @cartouche
13081 @noindent
13082 The meaning of @code{Storage_Size}. See 13.11(18).
13083 @end cartouche
13084 @noindent
13085 @code{Storage_Size} is measured in storage units, and refers to the
13086 total space available for an access type collection, or to the primary
13087 stack space for a task.
13088
13089 @sp 1
13090 @item
13091 @cartouche
13092 @noindent
13093 Implementation-defined aspects of storage pools. See
13094 13.11(22).
13095 @end cartouche
13096 @noindent
13097 See documentation in the sources of the run time mentioned in the
13098 paragraph about standard storage pools above
13099 for details on GNAT-defined aspects of storage pools.
13100
13101 @sp 1
13102 @item
13103 @cartouche
13104 @noindent
13105 The set of restrictions allowed in a pragma
13106 @code{Restrictions}. See 13.12(7).
13107 @end cartouche
13108 @noindent
13109 @xref{Standard and Implementation Defined Restrictions}.
13110
13111 @sp 1
13112 @item
13113 @cartouche
13114 @noindent
13115 The consequences of violating limitations on
13116 @code{Restrictions} pragmas. See 13.12(9).
13117 @end cartouche
13118 @noindent
13119 Restrictions that can be checked at compile time result in illegalities
13120 if violated. Currently there are no other consequences of violating
13121 restrictions.
13122
13123 @sp 1
13124 @item
13125 @cartouche
13126 @noindent
13127 The representation used by the @code{Read} and
13128 @code{Write} attributes of elementary types in terms of stream
13129 elements. See 13.13.2(9).
13130 @end cartouche
13131 @noindent
13132 The representation is the in-memory representation of the base type of
13133 the type, using the number of bits corresponding to the
13134 @code{@var{type}'Size} value, and the natural ordering of the machine.
13135
13136 @sp 1
13137 @item
13138 @cartouche
13139 @noindent
13140 The names and characteristics of the numeric subtypes
13141 declared in the visible part of package @code{Standard}. See A.1(3).
13142 @end cartouche
13143 @noindent
13144 See items describing the integer and floating-point types supported.
13145
13146 @sp 1
13147 @item
13148 @cartouche
13149 @noindent
13150 The string returned by @code{Character_Set_Version}.
13151 See A.3.5(3).
13152 @end cartouche
13153 @noindent
13154 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
13155 the string "Unicode 4.0", referring to version 4.0 of the
13156 Unicode specification.
13157
13158 @sp 1
13159 @item
13160 @cartouche
13161 @noindent
13162 The accuracy actually achieved by the elementary
13163 functions. See A.5.1(1).
13164 @end cartouche
13165 @noindent
13166 The elementary functions correspond to the functions available in the C
13167 library. Only fast math mode is implemented.
13168
13169 @sp 1
13170 @item
13171 @cartouche
13172 @noindent
13173 The sign of a zero result from some of the operators or
13174 functions in @code{Numerics.Generic_Elementary_Functions}, when
13175 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
13176 @end cartouche
13177 @noindent
13178 The sign of zeroes follows the requirements of the IEEE 754 standard on
13179 floating-point.
13180
13181 @sp 1
13182 @item
13183 @cartouche
13184 @noindent
13185 The value of
13186 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
13187 @end cartouche
13188 @noindent
13189 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13190
13191 @sp 1
13192 @item
13193 @cartouche
13194 @noindent
13195 The value of
13196 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
13197 @end cartouche
13198 @noindent
13199 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13200
13201 @sp 1
13202 @item
13203 @cartouche
13204 @noindent
13205 The algorithms for random number generation. See
13206 A.5.2(32).
13207 @end cartouche
13208 @noindent
13209 The algorithm is the Mersenne Twister, as documented in the source file
13210 @file{s-rannum.adb}. This version of the algorithm has a period of
13211 2**19937-1.
13212
13213 @sp 1
13214 @item
13215 @cartouche
13216 @noindent
13217 The string representation of a random number generator's
13218 state. See A.5.2(38).
13219 @end cartouche
13220 @noindent
13221 The value returned by the Image function is the concatenation of
13222 the fixed-width decimal representations of the 624 32-bit integers
13223 of the state vector.
13224
13225 @sp 1
13226 @item
13227 @cartouche
13228 @noindent
13229 The minimum time interval between calls to the
13230 time-dependent Reset procedure that are guaranteed to initiate different
13231 random number sequences. See A.5.2(45).
13232 @end cartouche
13233 @noindent
13234 The minimum period between reset calls to guarantee distinct series of
13235 random numbers is one microsecond.
13236
13237 @sp 1
13238 @item
13239 @cartouche
13240 @noindent
13241 The values of the @code{Model_Mantissa},
13242 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
13243 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
13244 Annex is not supported. See A.5.3(72).
13245 @end cartouche
13246 @noindent
13247 Run the compiler with @option{-gnatS} to produce a listing of package
13248 @code{Standard}, has the values of all numeric attributes.
13249
13250 @sp 1
13251 @item
13252 @cartouche
13253 @noindent
13254 Any implementation-defined characteristics of the
13255 input-output packages. See A.7(14).
13256 @end cartouche
13257 @noindent
13258 There are no special implementation defined characteristics for these
13259 packages.
13260
13261 @sp 1
13262 @item
13263 @cartouche
13264 @noindent
13265 The value of @code{Buffer_Size} in @code{Storage_IO}. See
13266 A.9(10).
13267 @end cartouche
13268 @noindent
13269 All type representations are contiguous, and the @code{Buffer_Size} is
13270 the value of @code{@var{type}'Size} rounded up to the next storage unit
13271 boundary.
13272
13273 @sp 1
13274 @item
13275 @cartouche
13276 @noindent
13277 External files for standard input, standard output, and
13278 standard error See A.10(5).
13279 @end cartouche
13280 @noindent
13281 These files are mapped onto the files provided by the C streams
13282 libraries. See source file @file{i-cstrea.ads} for further details.
13283
13284 @sp 1
13285 @item
13286 @cartouche
13287 @noindent
13288 The accuracy of the value produced by @code{Put}. See
13289 A.10.9(36).
13290 @end cartouche
13291 @noindent
13292 If more digits are requested in the output than are represented by the
13293 precision of the value, zeroes are output in the corresponding least
13294 significant digit positions.
13295
13296 @sp 1
13297 @item
13298 @cartouche
13299 @noindent
13300 The meaning of @code{Argument_Count}, @code{Argument}, and
13301 @code{Command_Name}. See A.15(1).
13302 @end cartouche
13303 @noindent
13304 These are mapped onto the @code{argv} and @code{argc} parameters of the
13305 main program in the natural manner.
13306
13307 @sp 1
13308 @item
13309 @cartouche
13310 @noindent
13311 The interpretation of the @code{Form} parameter in procedure
13312 @code{Create_Directory}. See A.16(56).
13313 @end cartouche
13314 @noindent
13315 The @code{Form} parameter is not used.
13316
13317 @sp 1
13318 @item
13319 @cartouche
13320 @noindent
13321 The interpretation of the @code{Form} parameter in procedure
13322 @code{Create_Path}. See A.16(60).
13323 @end cartouche
13324 @noindent
13325 The @code{Form} parameter is not used.
13326
13327 @sp 1
13328 @item
13329 @cartouche
13330 @noindent
13331 The interpretation of the @code{Form} parameter in procedure
13332 @code{Copy_File}. See A.16(68).
13333 @end cartouche
13334 @noindent
13335 The @code{Form} parameter is case-insensitive.
13336
13337 Two fields are recognized in the @code{Form} parameter:
13338
13339 @table @code
13340
13341 @item preserve=<value>
13342
13343 @item mode=<value>
13344
13345 @end table
13346
13347 @noindent
13348 <value> starts immediately after the character '=' and ends with the
13349 character immediately preceding the next comma (',') or with the last
13350 character of the parameter.
13351
13352 The only possible values for preserve= are:
13353
13354 @table @code
13355
13356 @item no_attributes
13357 Do not try to preserve any file attributes. This is the default if no
13358 preserve= is found in Form.
13359
13360 @item all_attributes
13361 Try to preserve all file attributes (timestamps, access rights).
13362
13363 @item timestamps
13364 Preserve the timestamp of the copied file, but not the other file attributes.
13365
13366 @end table
13367
13368 @noindent
13369 The only possible values for mode= are:
13370
13371 @table @code
13372
13373 @item copy
13374 Only do the copy if the destination file does not already exist. If it already
13375 exists, Copy_File fails.
13376
13377 @item overwrite
13378 Copy the file in all cases. Overwrite an already existing destination file.
13379
13380 @item append
13381 Append the original file to the destination file. If the destination file does
13382 not exist, the destination file is a copy of the source file. When mode=append,
13383 the field preserve=, if it exists, is not taken into account.
13384
13385 @end table
13386
13387 @noindent
13388 If the Form parameter includes one or both of the fields and the value or
13389 values are incorrect, Copy_file fails with Use_Error.
13390
13391 Examples of correct Forms:
13392
13393 @smallexample
13394 Form => "preserve=no_attributes,mode=overwrite" (the default)
13395 Form => "mode=append"
13396 Form => "mode=copy, preserve=all_attributes"
13397 @end smallexample
13398
13399 @noindent
13400 Examples of incorrect Forms
13401
13402 @smallexample
13403 Form => "preserve=junk"
13404 Form => "mode=internal, preserve=timestamps"
13405 @end smallexample
13406
13407 @sp 1
13408 @item
13409 @cartouche
13410 @noindent
13411 The interpretation of the @code{Pattern} parameter, when not the null string,
13412 in the @code{Start_Search} and @code{Search} procedures.
13413 See A.16(104) and A.16(112).
13414 @end cartouche
13415 @noindent
13416 When the @code{Pattern} parameter is not the null string, it is interpreted
13417 according to the syntax of regular expressions as defined in the
13418 @code{GNAT.Regexp} package.
13419 @xref{GNAT.Regexp (g-regexp.ads)}.
13420
13421 @sp 1
13422 @item
13423 @cartouche
13424 @noindent
13425 Implementation-defined convention names. See B.1(11).
13426 @end cartouche
13427 @noindent
13428 The following convention names are supported
13429
13430 @table @code
13431 @item Ada
13432 Ada
13433 @item Ada_Pass_By_Copy
13434 Allowed for any types except by-reference types such as limited
13435 records. Compatible with convention Ada, but causes any parameters
13436 with this convention to be passed by copy.
13437 @item Ada_Pass_By_Reference
13438 Allowed for any types except by-copy types such as scalars.
13439 Compatible with convention Ada, but causes any parameters
13440 with this convention to be passed by reference.
13441 @item Assembler
13442 Assembly language
13443 @item Asm
13444 Synonym for Assembler
13445 @item Assembly
13446 Synonym for Assembler
13447 @item C
13448 C
13449 @item C_Pass_By_Copy
13450 Allowed only for record types, like C, but also notes that record
13451 is to be passed by copy rather than reference.
13452 @item COBOL
13453 COBOL
13454 @item C_Plus_Plus (or CPP)
13455 C++
13456 @item Default
13457 Treated the same as C
13458 @item External
13459 Treated the same as C
13460 @item Fortran
13461 Fortran
13462 @item Intrinsic
13463 For support of pragma @code{Import} with convention Intrinsic, see
13464 separate section on Intrinsic Subprograms.
13465 @item Stdcall
13466 Stdcall (used for Windows implementations only). This convention correspond
13467 to the WINAPI (previously called Pascal convention) C/C++ convention under
13468 Windows. A routine with this convention cleans the stack before
13469 exit. This pragma cannot be applied to a dispatching call.
13470 @item DLL
13471 Synonym for Stdcall
13472 @item Win32
13473 Synonym for Stdcall
13474 @item Stubbed
13475 Stubbed is a special convention used to indicate that the body of the
13476 subprogram will be entirely ignored. Any call to the subprogram
13477 is converted into a raise of the @code{Program_Error} exception. If a
13478 pragma @code{Import} specifies convention @code{stubbed} then no body need
13479 be present at all. This convention is useful during development for the
13480 inclusion of subprograms whose body has not yet been written.
13481
13482 @end table
13483 @noindent
13484 In addition, all otherwise unrecognized convention names are also
13485 treated as being synonymous with convention C@. In all implementations
13486 except for VMS, use of such other names results in a warning. In VMS
13487 implementations, these names are accepted silently.
13488
13489 @sp 1
13490 @item
13491 @cartouche
13492 @noindent
13493 The meaning of link names. See B.1(36).
13494 @end cartouche
13495 @noindent
13496 Link names are the actual names used by the linker.
13497
13498 @sp 1
13499 @item
13500 @cartouche
13501 @noindent
13502 The manner of choosing link names when neither the link
13503 name nor the address of an imported or exported entity is specified. See
13504 B.1(36).
13505 @end cartouche
13506 @noindent
13507 The default linker name is that which would be assigned by the relevant
13508 external language, interpreting the Ada name as being in all lower case
13509 letters.
13510
13511 @sp 1
13512 @item
13513 @cartouche
13514 @noindent
13515 The effect of pragma @code{Linker_Options}. See B.1(37).
13516 @end cartouche
13517 @noindent
13518 The string passed to @code{Linker_Options} is presented uninterpreted as
13519 an argument to the link command, unless it contains ASCII.NUL characters.
13520 NUL characters if they appear act as argument separators, so for example
13521
13522 @smallexample @c ada
13523 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
13524 @end smallexample
13525
13526 @noindent
13527 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
13528 linker. The order of linker options is preserved for a given unit. The final
13529 list of options passed to the linker is in reverse order of the elaboration
13530 order. For example, linker options for a body always appear before the options
13531 from the corresponding package spec.
13532
13533 @sp 1
13534 @item
13535 @cartouche
13536 @noindent
13537 The contents of the visible part of package
13538 @code{Interfaces} and its language-defined descendants. See B.2(1).
13539 @end cartouche
13540 @noindent
13541 See files with prefix @file{i-} in the distributed library.
13542
13543 @sp 1
13544 @item
13545 @cartouche
13546 @noindent
13547 Implementation-defined children of package
13548 @code{Interfaces}. The contents of the visible part of package
13549 @code{Interfaces}. See B.2(11).
13550 @end cartouche
13551 @noindent
13552 See files with prefix @file{i-} in the distributed library.
13553
13554 @sp 1
13555 @item
13556 @cartouche
13557 @noindent
13558 The types @code{Floating}, @code{Long_Floating},
13559 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
13560 @code{COBOL_Character}; and the initialization of the variables
13561 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
13562 @code{Interfaces.COBOL}. See B.4(50).
13563 @end cartouche
13564 @noindent
13565 @table @code
13566 @item Floating
13567 Float
13568 @item Long_Floating
13569 (Floating) Long_Float
13570 @item Binary
13571 Integer
13572 @item Long_Binary
13573 Long_Long_Integer
13574 @item Decimal_Element
13575 Character
13576 @item COBOL_Character
13577 Character
13578 @end table
13579
13580 @noindent
13581 For initialization, see the file @file{i-cobol.ads} in the distributed library.
13582
13583 @sp 1
13584 @item
13585 @cartouche
13586 @noindent
13587 Support for access to machine instructions. See C.1(1).
13588 @end cartouche
13589 @noindent
13590 See documentation in file @file{s-maccod.ads} in the distributed library.
13591
13592 @sp 1
13593 @item
13594 @cartouche
13595 @noindent
13596 Implementation-defined aspects of access to machine
13597 operations. See C.1(9).
13598 @end cartouche
13599 @noindent
13600 See documentation in file @file{s-maccod.ads} in the distributed library.
13601
13602 @sp 1
13603 @item
13604 @cartouche
13605 @noindent
13606 Implementation-defined aspects of interrupts. See C.3(2).
13607 @end cartouche
13608 @noindent
13609 Interrupts are mapped to signals or conditions as appropriate. See
13610 definition of unit
13611 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
13612 on the interrupts supported on a particular target.
13613
13614 @sp 1
13615 @item
13616 @cartouche
13617 @noindent
13618 Implementation-defined aspects of pre-elaboration. See
13619 C.4(13).
13620 @end cartouche
13621 @noindent
13622 GNAT does not permit a partition to be restarted without reloading,
13623 except under control of the debugger.
13624
13625 @sp 1
13626 @item
13627 @cartouche
13628 @noindent
13629 The semantics of pragma @code{Discard_Names}. See C.5(7).
13630 @end cartouche
13631 @noindent
13632 Pragma @code{Discard_Names} causes names of enumeration literals to
13633 be suppressed. In the presence of this pragma, the Image attribute
13634 provides the image of the Pos of the literal, and Value accepts
13635 Pos values.
13636
13637 @sp 1
13638 @item
13639 @cartouche
13640 @noindent
13641 The result of the @code{Task_Identification.Image}
13642 attribute. See C.7.1(7).
13643 @end cartouche
13644 @noindent
13645 The result of this attribute is a string that identifies
13646 the object or component that denotes a given task. If a variable @code{Var}
13647 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
13648 where the suffix
13649 is the hexadecimal representation of the virtual address of the corresponding
13650 task control block. If the variable is an array of tasks, the image of each
13651 task will have the form of an indexed component indicating the position of a
13652 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
13653 component of a record, the image of the task will have the form of a selected
13654 component. These rules are fully recursive, so that the image of a task that
13655 is a subcomponent of a composite object corresponds to the expression that
13656 designates this task.
13657 @noindent
13658 If a task is created by an allocator, its image depends on the context. If the
13659 allocator is part of an object declaration, the rules described above are used
13660 to construct its image, and this image is not affected by subsequent
13661 assignments. If the allocator appears within an expression, the image
13662 includes only the name of the task type.
13663 @noindent
13664 If the configuration pragma Discard_Names is present, or if the restriction
13665 No_Implicit_Heap_Allocation is in effect, the image reduces to
13666 the numeric suffix, that is to say the hexadecimal representation of the
13667 virtual address of the control block of the task.
13668 @sp 1
13669 @item
13670 @cartouche
13671 @noindent
13672 The value of @code{Current_Task} when in a protected entry
13673 or interrupt handler. See C.7.1(17).
13674 @end cartouche
13675 @noindent
13676 Protected entries or interrupt handlers can be executed by any
13677 convenient thread, so the value of @code{Current_Task} is undefined.
13678
13679 @sp 1
13680 @item
13681 @cartouche
13682 @noindent
13683 The effect of calling @code{Current_Task} from an entry
13684 body or interrupt handler. See C.7.1(19).
13685 @end cartouche
13686 @noindent
13687 The effect of calling @code{Current_Task} from an entry body or
13688 interrupt handler is to return the identification of the task currently
13689 executing the code.
13690
13691 @sp 1
13692 @item
13693 @cartouche
13694 @noindent
13695 Implementation-defined aspects of
13696 @code{Task_Attributes}. See C.7.2(19).
13697 @end cartouche
13698 @noindent
13699 There are no implementation-defined aspects of @code{Task_Attributes}.
13700
13701 @sp 1
13702 @item
13703 @cartouche
13704 @noindent
13705 Values of all @code{Metrics}. See D(2).
13706 @end cartouche
13707 @noindent
13708 The metrics information for GNAT depends on the performance of the
13709 underlying operating system. The sources of the run-time for tasking
13710 implementation, together with the output from @option{-gnatG} can be
13711 used to determine the exact sequence of operating systems calls made
13712 to implement various tasking constructs. Together with appropriate
13713 information on the performance of the underlying operating system,
13714 on the exact target in use, this information can be used to determine
13715 the required metrics.
13716
13717 @sp 1
13718 @item
13719 @cartouche
13720 @noindent
13721 The declarations of @code{Any_Priority} and
13722 @code{Priority}. See D.1(11).
13723 @end cartouche
13724 @noindent
13725 See declarations in file @file{system.ads}.
13726
13727 @sp 1
13728 @item
13729 @cartouche
13730 @noindent
13731 Implementation-defined execution resources. See D.1(15).
13732 @end cartouche
13733 @noindent
13734 There are no implementation-defined execution resources.
13735
13736 @sp 1
13737 @item
13738 @cartouche
13739 @noindent
13740 Whether, on a multiprocessor, a task that is waiting for
13741 access to a protected object keeps its processor busy. See D.2.1(3).
13742 @end cartouche
13743 @noindent
13744 On a multi-processor, a task that is waiting for access to a protected
13745 object does not keep its processor busy.
13746
13747 @sp 1
13748 @item
13749 @cartouche
13750 @noindent
13751 The affect of implementation defined execution resources
13752 on task dispatching. See D.2.1(9).
13753 @end cartouche
13754 @noindent
13755 Tasks map to threads in the threads package used by GNAT@. Where possible
13756 and appropriate, these threads correspond to native threads of the
13757 underlying operating system.
13758
13759 @sp 1
13760 @item
13761 @cartouche
13762 @noindent
13763 Implementation-defined @code{policy_identifiers} allowed
13764 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
13765 @end cartouche
13766 @noindent
13767 There are no implementation-defined policy-identifiers allowed in this
13768 pragma.
13769
13770 @sp 1
13771 @item
13772 @cartouche
13773 @noindent
13774 Implementation-defined aspects of priority inversion. See
13775 D.2.2(16).
13776 @end cartouche
13777 @noindent
13778 Execution of a task cannot be preempted by the implementation processing
13779 of delay expirations for lower priority tasks.
13780
13781 @sp 1
13782 @item
13783 @cartouche
13784 @noindent
13785 Implementation-defined task dispatching. See D.2.2(18).
13786 @end cartouche
13787 @noindent
13788 The policy is the same as that of the underlying threads implementation.
13789
13790 @sp 1
13791 @item
13792 @cartouche
13793 @noindent
13794 Implementation-defined @code{policy_identifiers} allowed
13795 in a pragma @code{Locking_Policy}. See D.3(4).
13796 @end cartouche
13797 @noindent
13798 The two implementation defined policies permitted in GNAT are
13799 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
13800 targets that support the @code{Inheritance_Locking} policy, locking is
13801 implemented by inheritance, i.e.@: the task owning the lock operates
13802 at a priority equal to the highest priority of any task currently
13803 requesting the lock. On targets that support the
13804 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
13805 read/write lock allowing multiple propected object functions to enter
13806 concurrently.
13807
13808 @sp 1
13809 @item
13810 @cartouche
13811 @noindent
13812 Default ceiling priorities. See D.3(10).
13813 @end cartouche
13814 @noindent
13815 The ceiling priority of protected objects of the type
13816 @code{System.Interrupt_Priority'Last} as described in the Ada
13817 Reference Manual D.3(10),
13818
13819 @sp 1
13820 @item
13821 @cartouche
13822 @noindent
13823 The ceiling of any protected object used internally by
13824 the implementation. See D.3(16).
13825 @end cartouche
13826 @noindent
13827 The ceiling priority of internal protected objects is
13828 @code{System.Priority'Last}.
13829
13830 @sp 1
13831 @item
13832 @cartouche
13833 @noindent
13834 Implementation-defined queuing policies. See D.4(1).
13835 @end cartouche
13836 @noindent
13837 There are no implementation-defined queuing policies.
13838
13839 @sp 1
13840 @item
13841 @cartouche
13842 @noindent
13843 On a multiprocessor, any conditions that cause the
13844 completion of an aborted construct to be delayed later than what is
13845 specified for a single processor. See D.6(3).
13846 @end cartouche
13847 @noindent
13848 The semantics for abort on a multi-processor is the same as on a single
13849 processor, there are no further delays.
13850
13851 @sp 1
13852 @item
13853 @cartouche
13854 @noindent
13855 Any operations that implicitly require heap storage
13856 allocation. See D.7(8).
13857 @end cartouche
13858 @noindent
13859 The only operation that implicitly requires heap storage allocation is
13860 task creation.
13861
13862 @sp 1
13863 @item
13864 @cartouche
13865 @noindent
13866 Implementation-defined aspects of pragma
13867 @code{Restrictions}. See D.7(20).
13868 @end cartouche
13869 @noindent
13870 There are no such implementation-defined aspects.
13871
13872 @sp 1
13873 @item
13874 @cartouche
13875 @noindent
13876 Implementation-defined aspects of package
13877 @code{Real_Time}. See D.8(17).
13878 @end cartouche
13879 @noindent
13880 There are no implementation defined aspects of package @code{Real_Time}.
13881
13882 @sp 1
13883 @item
13884 @cartouche
13885 @noindent
13886 Implementation-defined aspects of
13887 @code{delay_statements}. See D.9(8).
13888 @end cartouche
13889 @noindent
13890 Any difference greater than one microsecond will cause the task to be
13891 delayed (see D.9(7)).
13892
13893 @sp 1
13894 @item
13895 @cartouche
13896 @noindent
13897 The upper bound on the duration of interrupt blocking
13898 caused by the implementation. See D.12(5).
13899 @end cartouche
13900 @noindent
13901 The upper bound is determined by the underlying operating system. In
13902 no cases is it more than 10 milliseconds.
13903
13904 @sp 1
13905 @item
13906 @cartouche
13907 @noindent
13908 The means for creating and executing distributed
13909 programs. See E(5).
13910 @end cartouche
13911 @noindent
13912 The GLADE package provides a utility GNATDIST for creating and executing
13913 distributed programs. See the GLADE reference manual for further details.
13914
13915 @sp 1
13916 @item
13917 @cartouche
13918 @noindent
13919 Any events that can result in a partition becoming
13920 inaccessible. See E.1(7).
13921 @end cartouche
13922 @noindent
13923 See the GLADE reference manual for full details on such events.
13924
13925 @sp 1
13926 @item
13927 @cartouche
13928 @noindent
13929 The scheduling policies, treatment of priorities, and
13930 management of shared resources between partitions in certain cases. See
13931 E.1(11).
13932 @end cartouche
13933 @noindent
13934 See the GLADE reference manual for full details on these aspects of
13935 multi-partition execution.
13936
13937 @sp 1
13938 @item
13939 @cartouche
13940 @noindent
13941 Events that cause the version of a compilation unit to
13942 change. See E.3(5).
13943 @end cartouche
13944 @noindent
13945 Editing the source file of a compilation unit, or the source files of
13946 any units on which it is dependent in a significant way cause the version
13947 to change. No other actions cause the version number to change. All changes
13948 are significant except those which affect only layout, capitalization or
13949 comments.
13950
13951 @sp 1
13952 @item
13953 @cartouche
13954 @noindent
13955 Whether the execution of the remote subprogram is
13956 immediately aborted as a result of cancellation. See E.4(13).
13957 @end cartouche
13958 @noindent
13959 See the GLADE reference manual for details on the effect of abort in
13960 a distributed application.
13961
13962 @sp 1
13963 @item
13964 @cartouche
13965 @noindent
13966 Implementation-defined aspects of the PCS@. See E.5(25).
13967 @end cartouche
13968 @noindent
13969 See the GLADE reference manual for a full description of all implementation
13970 defined aspects of the PCS@.
13971
13972 @sp 1
13973 @item
13974 @cartouche
13975 @noindent
13976 Implementation-defined interfaces in the PCS@. See
13977 E.5(26).
13978 @end cartouche
13979 @noindent
13980 See the GLADE reference manual for a full description of all
13981 implementation defined interfaces.
13982
13983 @sp 1
13984 @item
13985 @cartouche
13986 @noindent
13987 The values of named numbers in the package
13988 @code{Decimal}. See F.2(7).
13989 @end cartouche
13990 @noindent
13991 @table @code
13992 @item Max_Scale
13993 +18
13994 @item Min_Scale
13995 -18
13996 @item Min_Delta
13997 1.0E-18
13998 @item Max_Delta
13999 1.0E+18
14000 @item Max_Decimal_Digits
14001 18
14002 @end table
14003
14004 @sp 1
14005 @item
14006 @cartouche
14007 @noindent
14008 The value of @code{Max_Picture_Length} in the package
14009 @code{Text_IO.Editing}. See F.3.3(16).
14010 @end cartouche
14011 @noindent
14012 64
14013
14014 @sp 1
14015 @item
14016 @cartouche
14017 @noindent
14018 The value of @code{Max_Picture_Length} in the package
14019 @code{Wide_Text_IO.Editing}. See F.3.4(5).
14020 @end cartouche
14021 @noindent
14022 64
14023
14024 @sp 1
14025 @item
14026 @cartouche
14027 @noindent
14028 The accuracy actually achieved by the complex elementary
14029 functions and by other complex arithmetic operations. See G.1(1).
14030 @end cartouche
14031 @noindent
14032 Standard library functions are used for the complex arithmetic
14033 operations. Only fast math mode is currently supported.
14034
14035 @sp 1
14036 @item
14037 @cartouche
14038 @noindent
14039 The sign of a zero result (or a component thereof) from
14040 any operator or function in @code{Numerics.Generic_Complex_Types}, when
14041 @code{Real'Signed_Zeros} is True. See G.1.1(53).
14042 @end cartouche
14043 @noindent
14044 The signs of zero values are as recommended by the relevant
14045 implementation advice.
14046
14047 @sp 1
14048 @item
14049 @cartouche
14050 @noindent
14051 The sign of a zero result (or a component thereof) from
14052 any operator or function in
14053 @code{Numerics.Generic_Complex_Elementary_Functions}, when
14054 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
14055 @end cartouche
14056 @noindent
14057 The signs of zero values are as recommended by the relevant
14058 implementation advice.
14059
14060 @sp 1
14061 @item
14062 @cartouche
14063 @noindent
14064 Whether the strict mode or the relaxed mode is the
14065 default. See G.2(2).
14066 @end cartouche
14067 @noindent
14068 The strict mode is the default. There is no separate relaxed mode. GNAT
14069 provides a highly efficient implementation of strict mode.
14070
14071 @sp 1
14072 @item
14073 @cartouche
14074 @noindent
14075 The result interval in certain cases of fixed-to-float
14076 conversion. See G.2.1(10).
14077 @end cartouche
14078 @noindent
14079 For cases where the result interval is implementation dependent, the
14080 accuracy is that provided by performing all operations in 64-bit IEEE
14081 floating-point format.
14082
14083 @sp 1
14084 @item
14085 @cartouche
14086 @noindent
14087 The result of a floating point arithmetic operation in
14088 overflow situations, when the @code{Machine_Overflows} attribute of the
14089 result type is @code{False}. See G.2.1(13).
14090 @end cartouche
14091 @noindent
14092 Infinite and NaN values are produced as dictated by the IEEE
14093 floating-point standard.
14094
14095 Note that on machines that are not fully compliant with the IEEE
14096 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
14097 must be used for achieving IEEE conforming behavior (although at the cost
14098 of a significant performance penalty), so infinite and NaN values are
14099 properly generated.
14100
14101 @sp 1
14102 @item
14103 @cartouche
14104 @noindent
14105 The result interval for division (or exponentiation by a
14106 negative exponent), when the floating point hardware implements division
14107 as multiplication by a reciprocal. See G.2.1(16).
14108 @end cartouche
14109 @noindent
14110 Not relevant, division is IEEE exact.
14111
14112 @sp 1
14113 @item
14114 @cartouche
14115 @noindent
14116 The definition of close result set, which determines the
14117 accuracy of certain fixed point multiplications and divisions. See
14118 G.2.3(5).
14119 @end cartouche
14120 @noindent
14121 Operations in the close result set are performed using IEEE long format
14122 floating-point arithmetic. The input operands are converted to
14123 floating-point, the operation is done in floating-point, and the result
14124 is converted to the target type.
14125
14126 @sp 1
14127 @item
14128 @cartouche
14129 @noindent
14130 Conditions on a @code{universal_real} operand of a fixed
14131 point multiplication or division for which the result shall be in the
14132 perfect result set. See G.2.3(22).
14133 @end cartouche
14134 @noindent
14135 The result is only defined to be in the perfect result set if the result
14136 can be computed by a single scaling operation involving a scale factor
14137 representable in 64-bits.
14138
14139 @sp 1
14140 @item
14141 @cartouche
14142 @noindent
14143 The result of a fixed point arithmetic operation in
14144 overflow situations, when the @code{Machine_Overflows} attribute of the
14145 result type is @code{False}. See G.2.3(27).
14146 @end cartouche
14147 @noindent
14148 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
14149 types.
14150
14151 @sp 1
14152 @item
14153 @cartouche
14154 @noindent
14155 The result of an elementary function reference in
14156 overflow situations, when the @code{Machine_Overflows} attribute of the
14157 result type is @code{False}. See G.2.4(4).
14158 @end cartouche
14159 @noindent
14160 IEEE infinite and Nan values are produced as appropriate.
14161
14162 @sp 1
14163 @item
14164 @cartouche
14165 @noindent
14166 The value of the angle threshold, within which certain
14167 elementary functions, complex arithmetic operations, and complex
14168 elementary functions yield results conforming to a maximum relative
14169 error bound. See G.2.4(10).
14170 @end cartouche
14171 @noindent
14172 Information on this subject is not yet available.
14173
14174 @sp 1
14175 @item
14176 @cartouche
14177 @noindent
14178 The accuracy of certain elementary functions for
14179 parameters beyond the angle threshold. See G.2.4(10).
14180 @end cartouche
14181 @noindent
14182 Information on this subject is not yet available.
14183
14184 @sp 1
14185 @item
14186 @cartouche
14187 @noindent
14188 The result of a complex arithmetic operation or complex
14189 elementary function reference in overflow situations, when the
14190 @code{Machine_Overflows} attribute of the corresponding real type is
14191 @code{False}. See G.2.6(5).
14192 @end cartouche
14193 @noindent
14194 IEEE infinite and Nan values are produced as appropriate.
14195
14196 @sp 1
14197 @item
14198 @cartouche
14199 @noindent
14200 The accuracy of certain complex arithmetic operations and
14201 certain complex elementary functions for parameters (or components
14202 thereof) beyond the angle threshold. See G.2.6(8).
14203 @end cartouche
14204 @noindent
14205 Information on those subjects is not yet available.
14206
14207 @sp 1
14208 @item
14209 @cartouche
14210 @noindent
14211 Information regarding bounded errors and erroneous
14212 execution. See H.2(1).
14213 @end cartouche
14214 @noindent
14215 Information on this subject is not yet available.
14216
14217 @sp 1
14218 @item
14219 @cartouche
14220 @noindent
14221 Implementation-defined aspects of pragma
14222 @code{Inspection_Point}. See H.3.2(8).
14223 @end cartouche
14224 @noindent
14225 Pragma @code{Inspection_Point} ensures that the variable is live and can
14226 be examined by the debugger at the inspection point.
14227
14228 @sp 1
14229 @item
14230 @cartouche
14231 @noindent
14232 Implementation-defined aspects of pragma
14233 @code{Restrictions}. See H.4(25).
14234 @end cartouche
14235 @noindent
14236 There are no implementation-defined aspects of pragma @code{Restrictions}. The
14237 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
14238 generated code. Checks must suppressed by use of pragma @code{Suppress}.
14239
14240 @sp 1
14241 @item
14242 @cartouche
14243 @noindent
14244 Any restrictions on pragma @code{Restrictions}. See
14245 H.4(27).
14246 @end cartouche
14247 @noindent
14248 There are no restrictions on pragma @code{Restrictions}.
14249
14250 @end itemize
14251
14252
14253 @c =======================
14254 @node Intrinsic Subprograms
14255 @chapter Intrinsic Subprograms
14256 @cindex Intrinsic Subprograms
14257
14258 @menu
14259 * Intrinsic Operators::
14260 * Enclosing_Entity::
14261 * Exception_Information::
14262 * Exception_Message::
14263 * Exception_Name::
14264 * File::
14265 * Line::
14266 * Shifts and Rotates::
14267 * Source_Location::
14268 @end menu
14269
14270 @noindent
14271 GNAT allows a user application program to write the declaration:
14272
14273 @smallexample @c ada
14274 pragma Import (Intrinsic, name);
14275 @end smallexample
14276
14277 @noindent
14278 providing that the name corresponds to one of the implemented intrinsic
14279 subprograms in GNAT, and that the parameter profile of the referenced
14280 subprogram meets the requirements. This chapter describes the set of
14281 implemented intrinsic subprograms, and the requirements on parameter profiles.
14282 Note that no body is supplied; as with other uses of pragma Import, the
14283 body is supplied elsewhere (in this case by the compiler itself). Note
14284 that any use of this feature is potentially non-portable, since the
14285 Ada standard does not require Ada compilers to implement this feature.
14286
14287 @node Intrinsic Operators
14288 @section Intrinsic Operators
14289 @cindex Intrinsic operator
14290
14291 @noindent
14292 All the predefined numeric operators in package Standard
14293 in @code{pragma Import (Intrinsic,..)}
14294 declarations. In the binary operator case, the operands must have the same
14295 size. The operand or operands must also be appropriate for
14296 the operator. For example, for addition, the operands must
14297 both be floating-point or both be fixed-point, and the
14298 right operand for @code{"**"} must have a root type of
14299 @code{Standard.Integer'Base}.
14300 You can use an intrinsic operator declaration as in the following example:
14301
14302 @smallexample @c ada
14303 type Int1 is new Integer;
14304 type Int2 is new Integer;
14305
14306 function "+" (X1 : Int1; X2 : Int2) return Int1;
14307 function "+" (X1 : Int1; X2 : Int2) return Int2;
14308 pragma Import (Intrinsic, "+");
14309 @end smallexample
14310
14311 @noindent
14312 This declaration would permit ``mixed mode'' arithmetic on items
14313 of the differing types @code{Int1} and @code{Int2}.
14314 It is also possible to specify such operators for private types, if the
14315 full views are appropriate arithmetic types.
14316
14317 @node Enclosing_Entity
14318 @section Enclosing_Entity
14319 @cindex Enclosing_Entity
14320 @noindent
14321 This intrinsic subprogram is used in the implementation of the
14322 library routine @code{GNAT.Source_Info}. The only useful use of the
14323 intrinsic import in this case is the one in this unit, so an
14324 application program should simply call the function
14325 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
14326 the current subprogram, package, task, entry, or protected subprogram.
14327
14328 @node Exception_Information
14329 @section Exception_Information
14330 @cindex Exception_Information'
14331 @noindent
14332 This intrinsic subprogram is used in the implementation of the
14333 library routine @code{GNAT.Current_Exception}. The only useful
14334 use of the intrinsic import in this case is the one in this unit,
14335 so an application program should simply call the function
14336 @code{GNAT.Current_Exception.Exception_Information} to obtain
14337 the exception information associated with the current exception.
14338
14339 @node Exception_Message
14340 @section Exception_Message
14341 @cindex Exception_Message
14342 @noindent
14343 This intrinsic subprogram is used in the implementation of the
14344 library routine @code{GNAT.Current_Exception}. The only useful
14345 use of the intrinsic import in this case is the one in this unit,
14346 so an application program should simply call the function
14347 @code{GNAT.Current_Exception.Exception_Message} to obtain
14348 the message associated with the current exception.
14349
14350 @node Exception_Name
14351 @section Exception_Name
14352 @cindex Exception_Name
14353 @noindent
14354 This intrinsic subprogram is used in the implementation of the
14355 library routine @code{GNAT.Current_Exception}. The only useful
14356 use of the intrinsic import in this case is the one in this unit,
14357 so an application program should simply call the function
14358 @code{GNAT.Current_Exception.Exception_Name} to obtain
14359 the name of the current exception.
14360
14361 @node File
14362 @section File
14363 @cindex File
14364 @noindent
14365 This intrinsic subprogram is used in the implementation of the
14366 library routine @code{GNAT.Source_Info}. The only useful use of the
14367 intrinsic import in this case is the one in this unit, so an
14368 application program should simply call the function
14369 @code{GNAT.Source_Info.File} to obtain the name of the current
14370 file.
14371
14372 @node Line
14373 @section Line
14374 @cindex Line
14375 @noindent
14376 This intrinsic subprogram is used in the implementation of the
14377 library routine @code{GNAT.Source_Info}. The only useful use of the
14378 intrinsic import in this case is the one in this unit, so an
14379 application program should simply call the function
14380 @code{GNAT.Source_Info.Line} to obtain the number of the current
14381 source line.
14382
14383 @node Shifts and Rotates
14384 @section Shifts and Rotates
14385 @cindex Shift_Left
14386 @cindex Shift_Right
14387 @cindex Shift_Right_Arithmetic
14388 @cindex Rotate_Left
14389 @cindex Rotate_Right
14390 @noindent
14391 In standard Ada, the shift and rotate functions are available only
14392 for the predefined modular types in package @code{Interfaces}. However, in
14393 GNAT it is possible to define these functions for any integer
14394 type (signed or modular), as in this example:
14395
14396 @smallexample @c ada
14397 function Shift_Left
14398 (Value : T;
14399 Amount : Natural) return T;
14400 @end smallexample
14401
14402 @noindent
14403 The function name must be one of
14404 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
14405 Rotate_Right. T must be an integer type. T'Size must be
14406 8, 16, 32 or 64 bits; if T is modular, the modulus
14407 must be 2**8, 2**16, 2**32 or 2**64.
14408 The result type must be the same as the type of @code{Value}.
14409 The shift amount must be Natural.
14410 The formal parameter names can be anything.
14411
14412 A more convenient way of providing these shift operators is to use
14413 the Provide_Shift_Operators pragma, which provides the function declarations
14414 and corresponding pragma Import's for all five shift functions.
14415
14416 @node Source_Location
14417 @section Source_Location
14418 @cindex Source_Location
14419 @noindent
14420 This intrinsic subprogram is used in the implementation of the
14421 library routine @code{GNAT.Source_Info}. The only useful use of the
14422 intrinsic import in this case is the one in this unit, so an
14423 application program should simply call the function
14424 @code{GNAT.Source_Info.Source_Location} to obtain the current
14425 source file location.
14426
14427 @node Representation Clauses and Pragmas
14428 @chapter Representation Clauses and Pragmas
14429 @cindex Representation Clauses
14430
14431 @menu
14432 * Alignment Clauses::
14433 * Size Clauses::
14434 * Storage_Size Clauses::
14435 * Size of Variant Record Objects::
14436 * Biased Representation ::
14437 * Value_Size and Object_Size Clauses::
14438 * Component_Size Clauses::
14439 * Bit_Order Clauses::
14440 * Effect of Bit_Order on Byte Ordering::
14441 * Pragma Pack for Arrays::
14442 * Pragma Pack for Records::
14443 * Record Representation Clauses::
14444 * Handling of Records with Holes::
14445 * Enumeration Clauses::
14446 * Address Clauses::
14447 * Effect of Convention on Representation::
14448 * Conventions and Anonymous Access Types::
14449 * Determining the Representations chosen by GNAT::
14450 @end menu
14451
14452 @noindent
14453 @cindex Representation Clause
14454 @cindex Representation Pragma
14455 @cindex Pragma, representation
14456 This section describes the representation clauses accepted by GNAT, and
14457 their effect on the representation of corresponding data objects.
14458
14459 GNAT fully implements Annex C (Systems Programming). This means that all
14460 the implementation advice sections in chapter 13 are fully implemented.
14461 However, these sections only require a minimal level of support for
14462 representation clauses. GNAT provides much more extensive capabilities,
14463 and this section describes the additional capabilities provided.
14464
14465 @node Alignment Clauses
14466 @section Alignment Clauses
14467 @cindex Alignment Clause
14468
14469 @noindent
14470 GNAT requires that all alignment clauses specify a power of 2, and all
14471 default alignments are always a power of 2. The default alignment
14472 values are as follows:
14473
14474 @itemize @bullet
14475 @item @emph{Primitive Types}.
14476 For primitive types, the alignment is the minimum of the actual size of
14477 objects of the type divided by @code{Storage_Unit},
14478 and the maximum alignment supported by the target.
14479 (This maximum alignment is given by the GNAT-specific attribute
14480 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
14481 @cindex @code{Maximum_Alignment} attribute
14482 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
14483 default alignment will be 8 on any target that supports alignments
14484 this large, but on some targets, the maximum alignment may be smaller
14485 than 8, in which case objects of type @code{Long_Float} will be maximally
14486 aligned.
14487
14488 @item @emph{Arrays}.
14489 For arrays, the alignment is equal to the alignment of the component type
14490 for the normal case where no packing or component size is given. If the
14491 array is packed, and the packing is effective (see separate section on
14492 packed arrays), then the alignment will be one for long packed arrays,
14493 or arrays whose length is not known at compile time. For short packed
14494 arrays, which are handled internally as modular types, the alignment
14495 will be as described for primitive types, e.g.@: a packed array of length
14496 31 bits will have an object size of four bytes, and an alignment of 4.
14497
14498 @item @emph{Records}.
14499 For the normal non-packed case, the alignment of a record is equal to
14500 the maximum alignment of any of its components. For tagged records, this
14501 includes the implicit access type used for the tag. If a pragma @code{Pack}
14502 is used and all components are packable (see separate section on pragma
14503 @code{Pack}), then the resulting alignment is 1, unless the layout of the
14504 record makes it profitable to increase it.
14505
14506 A special case is when:
14507 @itemize @bullet
14508 @item
14509 the size of the record is given explicitly, or a
14510 full record representation clause is given, and
14511 @item
14512 the size of the record is 2, 4, or 8 bytes.
14513 @end itemize
14514 @noindent
14515 In this case, an alignment is chosen to match the
14516 size of the record. For example, if we have:
14517
14518 @smallexample @c ada
14519 type Small is record
14520 A, B : Character;
14521 end record;
14522 for Small'Size use 16;
14523 @end smallexample
14524
14525 @noindent
14526 then the default alignment of the record type @code{Small} is 2, not 1. This
14527 leads to more efficient code when the record is treated as a unit, and also
14528 allows the type to specified as @code{Atomic} on architectures requiring
14529 strict alignment.
14530
14531 @end itemize
14532
14533 @noindent
14534 An alignment clause may specify a larger alignment than the default value
14535 up to some maximum value dependent on the target (obtainable by using the
14536 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
14537 a smaller alignment than the default value for enumeration, integer and
14538 fixed point types, as well as for record types, for example
14539
14540 @smallexample @c ada
14541 type V is record
14542 A : Integer;
14543 end record;
14544
14545 for V'alignment use 1;
14546 @end smallexample
14547
14548 @noindent
14549 @cindex Alignment, default
14550 The default alignment for the type @code{V} is 4, as a result of the
14551 Integer field in the record, but it is permissible, as shown, to
14552 override the default alignment of the record with a smaller value.
14553
14554 @cindex Alignment, subtypes
14555 Note that according to the Ada standard, an alignment clause applies only
14556 to the first named subtype. If additional subtypes are declared, then the
14557 compiler is allowed to choose any alignment it likes, and there is no way
14558 to control this choice. Consider:
14559
14560 @smallexample @c ada
14561 type R is range 1 .. 10_000;
14562 for R'Alignment use 1;
14563 subtype RS is R range 1 .. 1000;
14564 @end smallexample
14565
14566 @noindent
14567 The alignment clause specifies an alignment of 1 for the first named subtype
14568 @code{R} but this does not necessarily apply to @code{RS}. When writing
14569 portable Ada code, you should avoid writing code that explicitly or
14570 implicitly relies on the alignment of such subtypes.
14571
14572 For the GNAT compiler, if an explicit alignment clause is given, this
14573 value is also used for any subsequent subtypes. So for GNAT, in the
14574 above example, you can count on the alignment of @code{RS} being 1. But this
14575 assumption is non-portable, and other compilers may choose different
14576 alignments for the subtype @code{RS}.
14577
14578 @node Size Clauses
14579 @section Size Clauses
14580 @cindex Size Clause
14581
14582 @noindent
14583 The default size for a type @code{T} is obtainable through the
14584 language-defined attribute @code{T'Size} and also through the
14585 equivalent GNAT-defined attribute @code{T'Value_Size}.
14586 For objects of type @code{T}, GNAT will generally increase the type size
14587 so that the object size (obtainable through the GNAT-defined attribute
14588 @code{T'Object_Size})
14589 is a multiple of @code{T'Alignment * Storage_Unit}.
14590 For example
14591
14592 @smallexample @c ada
14593 type Smallint is range 1 .. 6;
14594
14595 type Rec is record
14596 Y1 : integer;
14597 Y2 : boolean;
14598 end record;
14599 @end smallexample
14600
14601 @noindent
14602 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
14603 as specified by the RM rules,
14604 but objects of this type will have a size of 8
14605 (@code{Smallint'Object_Size} = 8),
14606 since objects by default occupy an integral number
14607 of storage units. On some targets, notably older
14608 versions of the Digital Alpha, the size of stand
14609 alone objects of this type may be 32, reflecting
14610 the inability of the hardware to do byte load/stores.
14611
14612 Similarly, the size of type @code{Rec} is 40 bits
14613 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
14614 the alignment is 4, so objects of this type will have
14615 their size increased to 64 bits so that it is a multiple
14616 of the alignment (in bits). This decision is
14617 in accordance with the specific Implementation Advice in RM 13.3(43):
14618
14619 @quotation
14620 A @code{Size} clause should be supported for an object if the specified
14621 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
14622 to a size in storage elements that is a multiple of the object's
14623 @code{Alignment} (if the @code{Alignment} is nonzero).
14624 @end quotation
14625
14626 @noindent
14627 An explicit size clause may be used to override the default size by
14628 increasing it. For example, if we have:
14629
14630 @smallexample @c ada
14631 type My_Boolean is new Boolean;
14632 for My_Boolean'Size use 32;
14633 @end smallexample
14634
14635 @noindent
14636 then values of this type will always be 32 bits long. In the case of
14637 discrete types, the size can be increased up to 64 bits, with the effect
14638 that the entire specified field is used to hold the value, sign- or
14639 zero-extended as appropriate. If more than 64 bits is specified, then
14640 padding space is allocated after the value, and a warning is issued that
14641 there are unused bits.
14642
14643 Similarly the size of records and arrays may be increased, and the effect
14644 is to add padding bits after the value. This also causes a warning message
14645 to be generated.
14646
14647 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
14648 Size in bits, this corresponds to an object of size 256 megabytes (minus
14649 one). This limitation is true on all targets. The reason for this
14650 limitation is that it improves the quality of the code in many cases
14651 if it is known that a Size value can be accommodated in an object of
14652 type Integer.
14653
14654 @node Storage_Size Clauses
14655 @section Storage_Size Clauses
14656 @cindex Storage_Size Clause
14657
14658 @noindent
14659 For tasks, the @code{Storage_Size} clause specifies the amount of space
14660 to be allocated for the task stack. This cannot be extended, and if the
14661 stack is exhausted, then @code{Storage_Error} will be raised (if stack
14662 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
14663 or a @code{Storage_Size} pragma in the task definition to set the
14664 appropriate required size. A useful technique is to include in every
14665 task definition a pragma of the form:
14666
14667 @smallexample @c ada
14668 pragma Storage_Size (Default_Stack_Size);
14669 @end smallexample
14670
14671 @noindent
14672 Then @code{Default_Stack_Size} can be defined in a global package, and
14673 modified as required. Any tasks requiring stack sizes different from the
14674 default can have an appropriate alternative reference in the pragma.
14675
14676 You can also use the @option{-d} binder switch to modify the default stack
14677 size.
14678
14679 For access types, the @code{Storage_Size} clause specifies the maximum
14680 space available for allocation of objects of the type. If this space is
14681 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
14682 In the case where the access type is declared local to a subprogram, the
14683 use of a @code{Storage_Size} clause triggers automatic use of a special
14684 predefined storage pool (@code{System.Pool_Size}) that ensures that all
14685 space for the pool is automatically reclaimed on exit from the scope in
14686 which the type is declared.
14687
14688 A special case recognized by the compiler is the specification of a
14689 @code{Storage_Size} of zero for an access type. This means that no
14690 items can be allocated from the pool, and this is recognized at compile
14691 time, and all the overhead normally associated with maintaining a fixed
14692 size storage pool is eliminated. Consider the following example:
14693
14694 @smallexample @c ada
14695 procedure p is
14696 type R is array (Natural) of Character;
14697 type P is access all R;
14698 for P'Storage_Size use 0;
14699 -- Above access type intended only for interfacing purposes
14700
14701 y : P;
14702
14703 procedure g (m : P);
14704 pragma Import (C, g);
14705
14706 -- @dots{}
14707
14708 begin
14709 -- @dots{}
14710 y := new R;
14711 end;
14712 @end smallexample
14713
14714 @noindent
14715 As indicated in this example, these dummy storage pools are often useful in
14716 connection with interfacing where no object will ever be allocated. If you
14717 compile the above example, you get the warning:
14718
14719 @smallexample
14720 p.adb:16:09: warning: allocation from empty storage pool
14721 p.adb:16:09: warning: Storage_Error will be raised at run time
14722 @end smallexample
14723
14724 @noindent
14725 Of course in practice, there will not be any explicit allocators in the
14726 case of such an access declaration.
14727
14728 @node Size of Variant Record Objects
14729 @section Size of Variant Record Objects
14730 @cindex Size, variant record objects
14731 @cindex Variant record objects, size
14732
14733 @noindent
14734 In the case of variant record objects, there is a question whether Size gives
14735 information about a particular variant, or the maximum size required
14736 for any variant. Consider the following program
14737
14738 @smallexample @c ada
14739 with Text_IO; use Text_IO;
14740 procedure q is
14741 type R1 (A : Boolean := False) is record
14742 case A is
14743 when True => X : Character;
14744 when False => null;
14745 end case;
14746 end record;
14747
14748 V1 : R1 (False);
14749 V2 : R1;
14750
14751 begin
14752 Put_Line (Integer'Image (V1'Size));
14753 Put_Line (Integer'Image (V2'Size));
14754 end q;
14755 @end smallexample
14756
14757 @noindent
14758 Here we are dealing with a variant record, where the True variant
14759 requires 16 bits, and the False variant requires 8 bits.
14760 In the above example, both V1 and V2 contain the False variant,
14761 which is only 8 bits long. However, the result of running the
14762 program is:
14763
14764 @smallexample
14765 8
14766 16
14767 @end smallexample
14768
14769 @noindent
14770 The reason for the difference here is that the discriminant value of
14771 V1 is fixed, and will always be False. It is not possible to assign
14772 a True variant value to V1, therefore 8 bits is sufficient. On the
14773 other hand, in the case of V2, the initial discriminant value is
14774 False (from the default), but it is possible to assign a True
14775 variant value to V2, therefore 16 bits must be allocated for V2
14776 in the general case, even fewer bits may be needed at any particular
14777 point during the program execution.
14778
14779 As can be seen from the output of this program, the @code{'Size}
14780 attribute applied to such an object in GNAT gives the actual allocated
14781 size of the variable, which is the largest size of any of the variants.
14782 The Ada Reference Manual is not completely clear on what choice should
14783 be made here, but the GNAT behavior seems most consistent with the
14784 language in the RM@.
14785
14786 In some cases, it may be desirable to obtain the size of the current
14787 variant, rather than the size of the largest variant. This can be
14788 achieved in GNAT by making use of the fact that in the case of a
14789 subprogram parameter, GNAT does indeed return the size of the current
14790 variant (because a subprogram has no way of knowing how much space
14791 is actually allocated for the actual).
14792
14793 Consider the following modified version of the above program:
14794
14795 @smallexample @c ada
14796 with Text_IO; use Text_IO;
14797 procedure q is
14798 type R1 (A : Boolean := False) is record
14799 case A is
14800 when True => X : Character;
14801 when False => null;
14802 end case;
14803 end record;
14804
14805 V2 : R1;
14806
14807 function Size (V : R1) return Integer is
14808 begin
14809 return V'Size;
14810 end Size;
14811
14812 begin
14813 Put_Line (Integer'Image (V2'Size));
14814 Put_Line (Integer'IMage (Size (V2)));
14815 V2 := (True, 'x');
14816 Put_Line (Integer'Image (V2'Size));
14817 Put_Line (Integer'IMage (Size (V2)));
14818 end q;
14819 @end smallexample
14820
14821 @noindent
14822 The output from this program is
14823
14824 @smallexample
14825 16
14826 8
14827 16
14828 16
14829 @end smallexample
14830
14831 @noindent
14832 Here we see that while the @code{'Size} attribute always returns
14833 the maximum size, regardless of the current variant value, the
14834 @code{Size} function does indeed return the size of the current
14835 variant value.
14836
14837 @node Biased Representation
14838 @section Biased Representation
14839 @cindex Size for biased representation
14840 @cindex Biased representation
14841
14842 @noindent
14843 In the case of scalars with a range starting at other than zero, it is
14844 possible in some cases to specify a size smaller than the default minimum
14845 value, and in such cases, GNAT uses an unsigned biased representation,
14846 in which zero is used to represent the lower bound, and successive values
14847 represent successive values of the type.
14848
14849 For example, suppose we have the declaration:
14850
14851 @smallexample @c ada
14852 type Small is range -7 .. -4;
14853 for Small'Size use 2;
14854 @end smallexample
14855
14856 @noindent
14857 Although the default size of type @code{Small} is 4, the @code{Size}
14858 clause is accepted by GNAT and results in the following representation
14859 scheme:
14860
14861 @smallexample
14862 -7 is represented as 2#00#
14863 -6 is represented as 2#01#
14864 -5 is represented as 2#10#
14865 -4 is represented as 2#11#
14866 @end smallexample
14867
14868 @noindent
14869 Biased representation is only used if the specified @code{Size} clause
14870 cannot be accepted in any other manner. These reduced sizes that force
14871 biased representation can be used for all discrete types except for
14872 enumeration types for which a representation clause is given.
14873
14874 @node Value_Size and Object_Size Clauses
14875 @section Value_Size and Object_Size Clauses
14876 @findex Value_Size
14877 @findex Object_Size
14878 @cindex Size, of objects
14879
14880 @noindent
14881 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
14882 number of bits required to hold values of type @code{T}.
14883 Although this interpretation was allowed in Ada 83, it was not required,
14884 and this requirement in practice can cause some significant difficulties.
14885 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
14886 However, in Ada 95 and Ada 2005,
14887 @code{Natural'Size} is
14888 typically 31. This means that code may change in behavior when moving
14889 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
14890
14891 @smallexample @c ada
14892 type Rec is record;
14893 A : Natural;
14894 B : Natural;
14895 end record;
14896
14897 for Rec use record
14898 at 0 range 0 .. Natural'Size - 1;
14899 at 0 range Natural'Size .. 2 * Natural'Size - 1;
14900 end record;
14901 @end smallexample
14902
14903 @noindent
14904 In the above code, since the typical size of @code{Natural} objects
14905 is 32 bits and @code{Natural'Size} is 31, the above code can cause
14906 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
14907 there are cases where the fact that the object size can exceed the
14908 size of the type causes surprises.
14909
14910 To help get around this problem GNAT provides two implementation
14911 defined attributes, @code{Value_Size} and @code{Object_Size}. When
14912 applied to a type, these attributes yield the size of the type
14913 (corresponding to the RM defined size attribute), and the size of
14914 objects of the type respectively.
14915
14916 The @code{Object_Size} is used for determining the default size of
14917 objects and components. This size value can be referred to using the
14918 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
14919 the basis of the determination of the size. The backend is free to
14920 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
14921 character might be stored in 32 bits on a machine with no efficient
14922 byte access instructions such as the Alpha.
14923
14924 The default rules for the value of @code{Object_Size} for
14925 discrete types are as follows:
14926
14927 @itemize @bullet
14928 @item
14929 The @code{Object_Size} for base subtypes reflect the natural hardware
14930 size in bits (run the compiler with @option{-gnatS} to find those values
14931 for numeric types). Enumeration types and fixed-point base subtypes have
14932 8, 16, 32 or 64 bits for this size, depending on the range of values
14933 to be stored.
14934
14935 @item
14936 The @code{Object_Size} of a subtype is the same as the
14937 @code{Object_Size} of
14938 the type from which it is obtained.
14939
14940 @item
14941 The @code{Object_Size} of a derived base type is copied from the parent
14942 base type, and the @code{Object_Size} of a derived first subtype is copied
14943 from the parent first subtype.
14944 @end itemize
14945
14946 @noindent
14947 The @code{Value_Size} attribute
14948 is the (minimum) number of bits required to store a value
14949 of the type.
14950 This value is used to determine how tightly to pack
14951 records or arrays with components of this type, and also affects
14952 the semantics of unchecked conversion (unchecked conversions where
14953 the @code{Value_Size} values differ generate a warning, and are potentially
14954 target dependent).
14955
14956 The default rules for the value of @code{Value_Size} are as follows:
14957
14958 @itemize @bullet
14959 @item
14960 The @code{Value_Size} for a base subtype is the minimum number of bits
14961 required to store all values of the type (including the sign bit
14962 only if negative values are possible).
14963
14964 @item
14965 If a subtype statically matches the first subtype of a given type, then it has
14966 by default the same @code{Value_Size} as the first subtype. This is a
14967 consequence of RM 13.1(14) (``if two subtypes statically match,
14968 then their subtype-specific aspects are the same''.)
14969
14970 @item
14971 All other subtypes have a @code{Value_Size} corresponding to the minimum
14972 number of bits required to store all values of the subtype. For
14973 dynamic bounds, it is assumed that the value can range down or up
14974 to the corresponding bound of the ancestor
14975 @end itemize
14976
14977 @noindent
14978 The RM defined attribute @code{Size} corresponds to the
14979 @code{Value_Size} attribute.
14980
14981 The @code{Size} attribute may be defined for a first-named subtype. This sets
14982 the @code{Value_Size} of
14983 the first-named subtype to the given value, and the
14984 @code{Object_Size} of this first-named subtype to the given value padded up
14985 to an appropriate boundary. It is a consequence of the default rules
14986 above that this @code{Object_Size} will apply to all further subtypes. On the
14987 other hand, @code{Value_Size} is affected only for the first subtype, any
14988 dynamic subtypes obtained from it directly, and any statically matching
14989 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
14990
14991 @code{Value_Size} and
14992 @code{Object_Size} may be explicitly set for any subtype using
14993 an attribute definition clause. Note that the use of these attributes
14994 can cause the RM 13.1(14) rule to be violated. If two access types
14995 reference aliased objects whose subtypes have differing @code{Object_Size}
14996 values as a result of explicit attribute definition clauses, then it
14997 is illegal to convert from one access subtype to the other. For a more
14998 complete description of this additional legality rule, see the
14999 description of the @code{Object_Size} attribute.
15000
15001 At the implementation level, Esize stores the Object_Size and the
15002 RM_Size field stores the @code{Value_Size} (and hence the value of the
15003 @code{Size} attribute,
15004 which, as noted above, is equivalent to @code{Value_Size}).
15005
15006 To get a feel for the difference, consider the following examples (note
15007 that in each case the base is @code{Short_Short_Integer} with a size of 8):
15008
15009 @smallexample
15010 Object_Size Value_Size
15011
15012 type x1 is range 0 .. 5; 8 3
15013
15014 type x2 is range 0 .. 5;
15015 for x2'size use 12; 16 12
15016
15017 subtype x3 is x2 range 0 .. 3; 16 2
15018
15019 subtype x4 is x2'base range 0 .. 10; 8 4
15020
15021 subtype x5 is x2 range 0 .. dynamic; 16 3*
15022
15023 subtype x6 is x2'base range 0 .. dynamic; 8 3*
15024
15025 @end smallexample
15026
15027 @noindent
15028 Note: the entries marked ``3*'' are not actually specified by the Ada
15029 Reference Manual, but it seems in the spirit of the RM rules to allocate
15030 the minimum number of bits (here 3, given the range for @code{x2})
15031 known to be large enough to hold the given range of values.
15032
15033 So far, so good, but GNAT has to obey the RM rules, so the question is
15034 under what conditions must the RM @code{Size} be used.
15035 The following is a list
15036 of the occasions on which the RM @code{Size} must be used:
15037
15038 @itemize @bullet
15039 @item
15040 Component size for packed arrays or records
15041
15042 @item
15043 Value of the attribute @code{Size} for a type
15044
15045 @item
15046 Warning about sizes not matching for unchecked conversion
15047 @end itemize
15048
15049 @noindent
15050 For record types, the @code{Object_Size} is always a multiple of the
15051 alignment of the type (this is true for all types). In some cases the
15052 @code{Value_Size} can be smaller. Consider:
15053
15054 @smallexample
15055 type R is record
15056 X : Integer;
15057 Y : Character;
15058 end record;
15059 @end smallexample
15060
15061 @noindent
15062 On a typical 32-bit architecture, the X component will be four bytes, and
15063 require four-byte alignment, and the Y component will be one byte. In this
15064 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
15065 required to store a value of this type, and for example, it is permissible
15066 to have a component of type R in an outer array whose component size is
15067 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
15068 since it must be rounded up so that this value is a multiple of the
15069 alignment (4 bytes = 32 bits).
15070
15071 @noindent
15072 For all other types, the @code{Object_Size}
15073 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
15074 Only @code{Size} may be specified for such types.
15075
15076 Note that @code{Value_Size} can be used to force biased representation
15077 for a particular subtype. Consider this example:
15078
15079 @smallexample
15080 type R is (A, B, C, D, E, F);
15081 subtype RAB is R range A .. B;
15082 subtype REF is R range E .. F;
15083 @end smallexample
15084
15085 @noindent
15086 By default, @code{RAB}
15087 has a size of 1 (sufficient to accommodate the representation
15088 of @code{A} and @code{B}, 0 and 1), and @code{REF}
15089 has a size of 3 (sufficient to accommodate the representation
15090 of @code{E} and @code{F}, 4 and 5). But if we add the
15091 following @code{Value_Size} attribute definition clause:
15092
15093 @smallexample
15094 for REF'Value_Size use 1;
15095 @end smallexample
15096
15097 @noindent
15098 then biased representation is forced for @code{REF},
15099 and 0 will represent @code{E} and 1 will represent @code{F}.
15100 A warning is issued when a @code{Value_Size} attribute
15101 definition clause forces biased representation. This
15102 warning can be turned off using @code{-gnatw.B}.
15103
15104 @node Component_Size Clauses
15105 @section Component_Size Clauses
15106 @cindex Component_Size Clause
15107
15108 @noindent
15109 Normally, the value specified in a component size clause must be consistent
15110 with the subtype of the array component with regard to size and alignment.
15111 In other words, the value specified must be at least equal to the size
15112 of this subtype, and must be a multiple of the alignment value.
15113
15114 In addition, component size clauses are allowed which cause the array
15115 to be packed, by specifying a smaller value. A first case is for
15116 component size values in the range 1 through 63. The value specified
15117 must not be smaller than the Size of the subtype. GNAT will accurately
15118 honor all packing requests in this range. For example, if we have:
15119
15120 @smallexample @c ada
15121 type r is array (1 .. 8) of Natural;
15122 for r'Component_Size use 31;
15123 @end smallexample
15124
15125 @noindent
15126 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
15127 Of course access to the components of such an array is considerably
15128 less efficient than if the natural component size of 32 is used.
15129 A second case is when the subtype of the component is a record type
15130 padded because of its default alignment. For example, if we have:
15131
15132 @smallexample @c ada
15133 type r is record
15134 i : Integer;
15135 j : Integer;
15136 b : Boolean;
15137 end record;
15138
15139 type a is array (1 .. 8) of r;
15140 for a'Component_Size use 72;
15141 @end smallexample
15142
15143 @noindent
15144 then the resulting array has a length of 72 bytes, instead of 96 bytes
15145 if the alignment of the record (4) was obeyed.
15146
15147 Note that there is no point in giving both a component size clause
15148 and a pragma Pack for the same array type. if such duplicate
15149 clauses are given, the pragma Pack will be ignored.
15150
15151 @node Bit_Order Clauses
15152 @section Bit_Order Clauses
15153 @cindex Bit_Order Clause
15154 @cindex bit ordering
15155 @cindex ordering, of bits
15156
15157 @noindent
15158 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
15159 attribute. The specification may either correspond to the default bit
15160 order for the target, in which case the specification has no effect and
15161 places no additional restrictions, or it may be for the non-standard
15162 setting (that is the opposite of the default).
15163
15164 In the case where the non-standard value is specified, the effect is
15165 to renumber bits within each byte, but the ordering of bytes is not
15166 affected. There are certain
15167 restrictions placed on component clauses as follows:
15168
15169 @itemize @bullet
15170
15171 @item Components fitting within a single storage unit.
15172 @noindent
15173 These are unrestricted, and the effect is merely to renumber bits. For
15174 example if we are on a little-endian machine with @code{Low_Order_First}
15175 being the default, then the following two declarations have exactly
15176 the same effect:
15177
15178 @smallexample @c ada
15179 type R1 is record
15180 A : Boolean;
15181 B : Integer range 1 .. 120;
15182 end record;
15183
15184 for R1 use record
15185 A at 0 range 0 .. 0;
15186 B at 0 range 1 .. 7;
15187 end record;
15188
15189 type R2 is record
15190 A : Boolean;
15191 B : Integer range 1 .. 120;
15192 end record;
15193
15194 for R2'Bit_Order use High_Order_First;
15195
15196 for R2 use record
15197 A at 0 range 7 .. 7;
15198 B at 0 range 0 .. 6;
15199 end record;
15200 @end smallexample
15201
15202 @noindent
15203 The useful application here is to write the second declaration with the
15204 @code{Bit_Order} attribute definition clause, and know that it will be treated
15205 the same, regardless of whether the target is little-endian or big-endian.
15206
15207 @item Components occupying an integral number of bytes.
15208 @noindent
15209 These are components that exactly fit in two or more bytes. Such component
15210 declarations are allowed, but have no effect, since it is important to realize
15211 that the @code{Bit_Order} specification does not affect the ordering of bytes.
15212 In particular, the following attempt at getting an endian-independent integer
15213 does not work:
15214
15215 @smallexample @c ada
15216 type R2 is record
15217 A : Integer;
15218 end record;
15219
15220 for R2'Bit_Order use High_Order_First;
15221
15222 for R2 use record
15223 A at 0 range 0 .. 31;
15224 end record;
15225 @end smallexample
15226
15227 @noindent
15228 This declaration will result in a little-endian integer on a
15229 little-endian machine, and a big-endian integer on a big-endian machine.
15230 If byte flipping is required for interoperability between big- and
15231 little-endian machines, this must be explicitly programmed. This capability
15232 is not provided by @code{Bit_Order}.
15233
15234 @item Components that are positioned across byte boundaries
15235 @noindent
15236 but do not occupy an integral number of bytes. Given that bytes are not
15237 reordered, such fields would occupy a non-contiguous sequence of bits
15238 in memory, requiring non-trivial code to reassemble. They are for this
15239 reason not permitted, and any component clause specifying such a layout
15240 will be flagged as illegal by GNAT@.
15241
15242 @end itemize
15243
15244 @noindent
15245 Since the misconception that Bit_Order automatically deals with all
15246 endian-related incompatibilities is a common one, the specification of
15247 a component field that is an integral number of bytes will always
15248 generate a warning. This warning may be suppressed using @code{pragma
15249 Warnings (Off)} if desired. The following section contains additional
15250 details regarding the issue of byte ordering.
15251
15252 @node Effect of Bit_Order on Byte Ordering
15253 @section Effect of Bit_Order on Byte Ordering
15254 @cindex byte ordering
15255 @cindex ordering, of bytes
15256
15257 @noindent
15258 In this section we will review the effect of the @code{Bit_Order} attribute
15259 definition clause on byte ordering. Briefly, it has no effect at all, but
15260 a detailed example will be helpful. Before giving this
15261 example, let us review the precise
15262 definition of the effect of defining @code{Bit_Order}. The effect of a
15263 non-standard bit order is described in section 15.5.3 of the Ada
15264 Reference Manual:
15265
15266 @quotation
15267 2 A bit ordering is a method of interpreting the meaning of
15268 the storage place attributes.
15269 @end quotation
15270
15271 @noindent
15272 To understand the precise definition of storage place attributes in
15273 this context, we visit section 13.5.1 of the manual:
15274
15275 @quotation
15276 13 A record_representation_clause (without the mod_clause)
15277 specifies the layout. The storage place attributes (see 13.5.2)
15278 are taken from the values of the position, first_bit, and last_bit
15279 expressions after normalizing those values so that first_bit is
15280 less than Storage_Unit.
15281 @end quotation
15282
15283 @noindent
15284 The critical point here is that storage places are taken from
15285 the values after normalization, not before. So the @code{Bit_Order}
15286 interpretation applies to normalized values. The interpretation
15287 is described in the later part of the 15.5.3 paragraph:
15288
15289 @quotation
15290 2 A bit ordering is a method of interpreting the meaning of
15291 the storage place attributes. High_Order_First (known in the
15292 vernacular as ``big endian'') means that the first bit of a
15293 storage element (bit 0) is the most significant bit (interpreting
15294 the sequence of bits that represent a component as an unsigned
15295 integer value). Low_Order_First (known in the vernacular as
15296 ``little endian'') means the opposite: the first bit is the
15297 least significant.
15298 @end quotation
15299
15300 @noindent
15301 Note that the numbering is with respect to the bits of a storage
15302 unit. In other words, the specification affects only the numbering
15303 of bits within a single storage unit.
15304
15305 We can make the effect clearer by giving an example.
15306
15307 Suppose that we have an external device which presents two bytes, the first
15308 byte presented, which is the first (low addressed byte) of the two byte
15309 record is called Master, and the second byte is called Slave.
15310
15311 The left most (most significant bit is called Control for each byte, and
15312 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
15313 (least significant) bit.
15314
15315 On a big-endian machine, we can write the following representation clause
15316
15317 @smallexample @c ada
15318 type Data is record
15319 Master_Control : Bit;
15320 Master_V1 : Bit;
15321 Master_V2 : Bit;
15322 Master_V3 : Bit;
15323 Master_V4 : Bit;
15324 Master_V5 : Bit;
15325 Master_V6 : Bit;
15326 Master_V7 : Bit;
15327 Slave_Control : Bit;
15328 Slave_V1 : Bit;
15329 Slave_V2 : Bit;
15330 Slave_V3 : Bit;
15331 Slave_V4 : Bit;
15332 Slave_V5 : Bit;
15333 Slave_V6 : Bit;
15334 Slave_V7 : Bit;
15335 end record;
15336
15337 for Data use record
15338 Master_Control at 0 range 0 .. 0;
15339 Master_V1 at 0 range 1 .. 1;
15340 Master_V2 at 0 range 2 .. 2;
15341 Master_V3 at 0 range 3 .. 3;
15342 Master_V4 at 0 range 4 .. 4;
15343 Master_V5 at 0 range 5 .. 5;
15344 Master_V6 at 0 range 6 .. 6;
15345 Master_V7 at 0 range 7 .. 7;
15346 Slave_Control at 1 range 0 .. 0;
15347 Slave_V1 at 1 range 1 .. 1;
15348 Slave_V2 at 1 range 2 .. 2;
15349 Slave_V3 at 1 range 3 .. 3;
15350 Slave_V4 at 1 range 4 .. 4;
15351 Slave_V5 at 1 range 5 .. 5;
15352 Slave_V6 at 1 range 6 .. 6;
15353 Slave_V7 at 1 range 7 .. 7;
15354 end record;
15355 @end smallexample
15356
15357 @noindent
15358 Now if we move this to a little endian machine, then the bit ordering within
15359 the byte is backwards, so we have to rewrite the record rep clause as:
15360
15361 @smallexample @c ada
15362 for Data use record
15363 Master_Control at 0 range 7 .. 7;
15364 Master_V1 at 0 range 6 .. 6;
15365 Master_V2 at 0 range 5 .. 5;
15366 Master_V3 at 0 range 4 .. 4;
15367 Master_V4 at 0 range 3 .. 3;
15368 Master_V5 at 0 range 2 .. 2;
15369 Master_V6 at 0 range 1 .. 1;
15370 Master_V7 at 0 range 0 .. 0;
15371 Slave_Control at 1 range 7 .. 7;
15372 Slave_V1 at 1 range 6 .. 6;
15373 Slave_V2 at 1 range 5 .. 5;
15374 Slave_V3 at 1 range 4 .. 4;
15375 Slave_V4 at 1 range 3 .. 3;
15376 Slave_V5 at 1 range 2 .. 2;
15377 Slave_V6 at 1 range 1 .. 1;
15378 Slave_V7 at 1 range 0 .. 0;
15379 end record;
15380 @end smallexample
15381
15382 @noindent
15383 It is a nuisance to have to rewrite the clause, especially if
15384 the code has to be maintained on both machines. However,
15385 this is a case that we can handle with the
15386 @code{Bit_Order} attribute if it is implemented.
15387 Note that the implementation is not required on byte addressed
15388 machines, but it is indeed implemented in GNAT.
15389 This means that we can simply use the
15390 first record clause, together with the declaration
15391
15392 @smallexample @c ada
15393 for Data'Bit_Order use High_Order_First;
15394 @end smallexample
15395
15396 @noindent
15397 and the effect is what is desired, namely the layout is exactly the same,
15398 independent of whether the code is compiled on a big-endian or little-endian
15399 machine.
15400
15401 The important point to understand is that byte ordering is not affected.
15402 A @code{Bit_Order} attribute definition never affects which byte a field
15403 ends up in, only where it ends up in that byte.
15404 To make this clear, let us rewrite the record rep clause of the previous
15405 example as:
15406
15407 @smallexample @c ada
15408 for Data'Bit_Order use High_Order_First;
15409 for Data use record
15410 Master_Control at 0 range 0 .. 0;
15411 Master_V1 at 0 range 1 .. 1;
15412 Master_V2 at 0 range 2 .. 2;
15413 Master_V3 at 0 range 3 .. 3;
15414 Master_V4 at 0 range 4 .. 4;
15415 Master_V5 at 0 range 5 .. 5;
15416 Master_V6 at 0 range 6 .. 6;
15417 Master_V7 at 0 range 7 .. 7;
15418 Slave_Control at 0 range 8 .. 8;
15419 Slave_V1 at 0 range 9 .. 9;
15420 Slave_V2 at 0 range 10 .. 10;
15421 Slave_V3 at 0 range 11 .. 11;
15422 Slave_V4 at 0 range 12 .. 12;
15423 Slave_V5 at 0 range 13 .. 13;
15424 Slave_V6 at 0 range 14 .. 14;
15425 Slave_V7 at 0 range 15 .. 15;
15426 end record;
15427 @end smallexample
15428
15429 @noindent
15430 This is exactly equivalent to saying (a repeat of the first example):
15431
15432 @smallexample @c ada
15433 for Data'Bit_Order use High_Order_First;
15434 for Data use record
15435 Master_Control at 0 range 0 .. 0;
15436 Master_V1 at 0 range 1 .. 1;
15437 Master_V2 at 0 range 2 .. 2;
15438 Master_V3 at 0 range 3 .. 3;
15439 Master_V4 at 0 range 4 .. 4;
15440 Master_V5 at 0 range 5 .. 5;
15441 Master_V6 at 0 range 6 .. 6;
15442 Master_V7 at 0 range 7 .. 7;
15443 Slave_Control at 1 range 0 .. 0;
15444 Slave_V1 at 1 range 1 .. 1;
15445 Slave_V2 at 1 range 2 .. 2;
15446 Slave_V3 at 1 range 3 .. 3;
15447 Slave_V4 at 1 range 4 .. 4;
15448 Slave_V5 at 1 range 5 .. 5;
15449 Slave_V6 at 1 range 6 .. 6;
15450 Slave_V7 at 1 range 7 .. 7;
15451 end record;
15452 @end smallexample
15453
15454 @noindent
15455 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
15456 field. The storage place attributes are obtained by normalizing the
15457 values given so that the @code{First_Bit} value is less than 8. After
15458 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
15459 we specified in the other case.
15460
15461 Now one might expect that the @code{Bit_Order} attribute might affect
15462 bit numbering within the entire record component (two bytes in this
15463 case, thus affecting which byte fields end up in), but that is not
15464 the way this feature is defined, it only affects numbering of bits,
15465 not which byte they end up in.
15466
15467 Consequently it never makes sense to specify a starting bit number
15468 greater than 7 (for a byte addressable field) if an attribute
15469 definition for @code{Bit_Order} has been given, and indeed it
15470 may be actively confusing to specify such a value, so the compiler
15471 generates a warning for such usage.
15472
15473 If you do need to control byte ordering then appropriate conditional
15474 values must be used. If in our example, the slave byte came first on
15475 some machines we might write:
15476
15477 @smallexample @c ada
15478 Master_Byte_First constant Boolean := @dots{};
15479
15480 Master_Byte : constant Natural :=
15481 1 - Boolean'Pos (Master_Byte_First);
15482 Slave_Byte : constant Natural :=
15483 Boolean'Pos (Master_Byte_First);
15484
15485 for Data'Bit_Order use High_Order_First;
15486 for Data use record
15487 Master_Control at Master_Byte range 0 .. 0;
15488 Master_V1 at Master_Byte range 1 .. 1;
15489 Master_V2 at Master_Byte range 2 .. 2;
15490 Master_V3 at Master_Byte range 3 .. 3;
15491 Master_V4 at Master_Byte range 4 .. 4;
15492 Master_V5 at Master_Byte range 5 .. 5;
15493 Master_V6 at Master_Byte range 6 .. 6;
15494 Master_V7 at Master_Byte range 7 .. 7;
15495 Slave_Control at Slave_Byte range 0 .. 0;
15496 Slave_V1 at Slave_Byte range 1 .. 1;
15497 Slave_V2 at Slave_Byte range 2 .. 2;
15498 Slave_V3 at Slave_Byte range 3 .. 3;
15499 Slave_V4 at Slave_Byte range 4 .. 4;
15500 Slave_V5 at Slave_Byte range 5 .. 5;
15501 Slave_V6 at Slave_Byte range 6 .. 6;
15502 Slave_V7 at Slave_Byte range 7 .. 7;
15503 end record;
15504 @end smallexample
15505
15506 @noindent
15507 Now to switch between machines, all that is necessary is
15508 to set the boolean constant @code{Master_Byte_First} in
15509 an appropriate manner.
15510
15511 @node Pragma Pack for Arrays
15512 @section Pragma Pack for Arrays
15513 @cindex Pragma Pack (for arrays)
15514
15515 @noindent
15516 Pragma @code{Pack} applied to an array has no effect unless the component type
15517 is packable. For a component type to be packable, it must be one of the
15518 following cases:
15519
15520 @itemize @bullet
15521 @item
15522 Any scalar type
15523 @item
15524 Any type whose size is specified with a size clause
15525 @item
15526 Any packed array type with a static size
15527 @item
15528 Any record type padded because of its default alignment
15529 @end itemize
15530
15531 @noindent
15532 For all these cases, if the component subtype size is in the range
15533 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
15534 component size were specified giving the component subtype size.
15535 For example if we have:
15536
15537 @smallexample @c ada
15538 type r is range 0 .. 17;
15539
15540 type ar is array (1 .. 8) of r;
15541 pragma Pack (ar);
15542 @end smallexample
15543
15544 @noindent
15545 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
15546 and the size of the array @code{ar} will be exactly 40 bits.
15547
15548 Note that in some cases this rather fierce approach to packing can produce
15549 unexpected effects. For example, in Ada 95 and Ada 2005,
15550 subtype @code{Natural} typically has a size of 31, meaning that if you
15551 pack an array of @code{Natural}, you get 31-bit
15552 close packing, which saves a few bits, but results in far less efficient
15553 access. Since many other Ada compilers will ignore such a packing request,
15554 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
15555 might not be what is intended. You can easily remove this warning by
15556 using an explicit @code{Component_Size} setting instead, which never generates
15557 a warning, since the intention of the programmer is clear in this case.
15558
15559 GNAT treats packed arrays in one of two ways. If the size of the array is
15560 known at compile time and is less than 64 bits, then internally the array
15561 is represented as a single modular type, of exactly the appropriate number
15562 of bits. If the length is greater than 63 bits, or is not known at compile
15563 time, then the packed array is represented as an array of bytes, and the
15564 length is always a multiple of 8 bits.
15565
15566 Note that to represent a packed array as a modular type, the alignment must
15567 be suitable for the modular type involved. For example, on typical machines
15568 a 32-bit packed array will be represented by a 32-bit modular integer with
15569 an alignment of four bytes. If you explicitly override the default alignment
15570 with an alignment clause that is too small, the modular representation
15571 cannot be used. For example, consider the following set of declarations:
15572
15573 @smallexample @c ada
15574 type R is range 1 .. 3;
15575 type S is array (1 .. 31) of R;
15576 for S'Component_Size use 2;
15577 for S'Size use 62;
15578 for S'Alignment use 1;
15579 @end smallexample
15580
15581 @noindent
15582 If the alignment clause were not present, then a 62-bit modular
15583 representation would be chosen (typically with an alignment of 4 or 8
15584 bytes depending on the target). But the default alignment is overridden
15585 with the explicit alignment clause. This means that the modular
15586 representation cannot be used, and instead the array of bytes
15587 representation must be used, meaning that the length must be a multiple
15588 of 8. Thus the above set of declarations will result in a diagnostic
15589 rejecting the size clause and noting that the minimum size allowed is 64.
15590
15591 @cindex Pragma Pack (for type Natural)
15592 @cindex Pragma Pack warning
15593
15594 One special case that is worth noting occurs when the base type of the
15595 component size is 8/16/32 and the subtype is one bit less. Notably this
15596 occurs with subtype @code{Natural}. Consider:
15597
15598 @smallexample @c ada
15599 type Arr is array (1 .. 32) of Natural;
15600 pragma Pack (Arr);
15601 @end smallexample
15602
15603 @noindent
15604 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
15605 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
15606 Ada 83 compilers did not attempt 31 bit packing.
15607
15608 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
15609 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
15610 substantial unintended performance penalty when porting legacy Ada 83 code.
15611 To help prevent this, GNAT generates a warning in such cases. If you really
15612 want 31 bit packing in a case like this, you can set the component size
15613 explicitly:
15614
15615 @smallexample @c ada
15616 type Arr is array (1 .. 32) of Natural;
15617 for Arr'Component_Size use 31;
15618 @end smallexample
15619
15620 @noindent
15621 Here 31-bit packing is achieved as required, and no warning is generated,
15622 since in this case the programmer intention is clear.
15623
15624 @node Pragma Pack for Records
15625 @section Pragma Pack for Records
15626 @cindex Pragma Pack (for records)
15627
15628 @noindent
15629 Pragma @code{Pack} applied to a record will pack the components to reduce
15630 wasted space from alignment gaps and by reducing the amount of space
15631 taken by components. We distinguish between @emph{packable} components and
15632 @emph{non-packable} components.
15633 Components of the following types are considered packable:
15634 @itemize @bullet
15635 @item
15636 Components of a primitive type are packable unless they are aliased
15637 or of an atomic type.
15638
15639 @item
15640 Small packed arrays, whose size does not exceed 64 bits, and where the
15641 size is statically known at compile time, are represented internally
15642 as modular integers, and so they are also packable.
15643
15644 @end itemize
15645
15646 @noindent
15647 All packable components occupy the exact number of bits corresponding to
15648 their @code{Size} value, and are packed with no padding bits, i.e.@: they
15649 can start on an arbitrary bit boundary.
15650
15651 All other types are non-packable, they occupy an integral number of
15652 storage units, and
15653 are placed at a boundary corresponding to their alignment requirements.
15654
15655 For example, consider the record
15656
15657 @smallexample @c ada
15658 type Rb1 is array (1 .. 13) of Boolean;
15659 pragma Pack (Rb1);
15660
15661 type Rb2 is array (1 .. 65) of Boolean;
15662 pragma Pack (Rb2);
15663
15664 type AF is new Float with Atomic;
15665
15666 type X2 is record
15667 L1 : Boolean;
15668 L2 : Duration;
15669 L3 : AF;
15670 L4 : Boolean;
15671 L5 : Rb1;
15672 L6 : Rb2;
15673 end record;
15674 pragma Pack (X2);
15675 @end smallexample
15676
15677 @noindent
15678 The representation for the record X2 is as follows:
15679
15680 @smallexample @c ada
15681 for X2'Size use 224;
15682 for X2 use record
15683 L1 at 0 range 0 .. 0;
15684 L2 at 0 range 1 .. 64;
15685 L3 at 12 range 0 .. 31;
15686 L4 at 16 range 0 .. 0;
15687 L5 at 16 range 1 .. 13;
15688 L6 at 18 range 0 .. 71;
15689 end record;
15690 @end smallexample
15691
15692 @noindent
15693 Studying this example, we see that the packable fields @code{L1}
15694 and @code{L2} are
15695 of length equal to their sizes, and placed at specific bit boundaries (and
15696 not byte boundaries) to
15697 eliminate padding. But @code{L3} is of a non-packable float type (because
15698 it is aliased), so it is on the next appropriate alignment boundary.
15699
15700 The next two fields are fully packable, so @code{L4} and @code{L5} are
15701 minimally packed with no gaps. However, type @code{Rb2} is a packed
15702 array that is longer than 64 bits, so it is itself non-packable. Thus
15703 the @code{L6} field is aligned to the next byte boundary, and takes an
15704 integral number of bytes, i.e.@: 72 bits.
15705
15706 @node Record Representation Clauses
15707 @section Record Representation Clauses
15708 @cindex Record Representation Clause
15709
15710 @noindent
15711 Record representation clauses may be given for all record types, including
15712 types obtained by record extension. Component clauses are allowed for any
15713 static component. The restrictions on component clauses depend on the type
15714 of the component.
15715
15716 @cindex Component Clause
15717 For all components of an elementary type, the only restriction on component
15718 clauses is that the size must be at least the 'Size value of the type
15719 (actually the Value_Size). There are no restrictions due to alignment,
15720 and such components may freely cross storage boundaries.
15721
15722 Packed arrays with a size up to and including 64 bits are represented
15723 internally using a modular type with the appropriate number of bits, and
15724 thus the same lack of restriction applies. For example, if you declare:
15725
15726 @smallexample @c ada
15727 type R is array (1 .. 49) of Boolean;
15728 pragma Pack (R);
15729 for R'Size use 49;
15730 @end smallexample
15731
15732 @noindent
15733 then a component clause for a component of type R may start on any
15734 specified bit boundary, and may specify a value of 49 bits or greater.
15735
15736 For packed bit arrays that are longer than 64 bits, there are two
15737 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
15738 including the important case of single bits or boolean values, then
15739 there are no limitations on placement of such components, and they
15740 may start and end at arbitrary bit boundaries.
15741
15742 If the component size is not a power of 2 (e.g.@: 3 or 5), then
15743 an array of this type longer than 64 bits must always be placed on
15744 on a storage unit (byte) boundary and occupy an integral number
15745 of storage units (bytes). Any component clause that does not
15746 meet this requirement will be rejected.
15747
15748 Any aliased component, or component of an aliased type, must
15749 have its normal alignment and size. A component clause that
15750 does not meet this requirement will be rejected.
15751
15752 The tag field of a tagged type always occupies an address sized field at
15753 the start of the record. No component clause may attempt to overlay this
15754 tag. When a tagged type appears as a component, the tag field must have
15755 proper alignment
15756
15757 In the case of a record extension T1, of a type T, no component clause applied
15758 to the type T1 can specify a storage location that would overlap the first
15759 T'Size bytes of the record.
15760
15761 For all other component types, including non-bit-packed arrays,
15762 the component can be placed at an arbitrary bit boundary,
15763 so for example, the following is permitted:
15764
15765 @smallexample @c ada
15766 type R is array (1 .. 10) of Boolean;
15767 for R'Size use 80;
15768
15769 type Q is record
15770 G, H : Boolean;
15771 L, M : R;
15772 end record;
15773
15774 for Q use record
15775 G at 0 range 0 .. 0;
15776 H at 0 range 1 .. 1;
15777 L at 0 range 2 .. 81;
15778 R at 0 range 82 .. 161;
15779 end record;
15780 @end smallexample
15781
15782 @noindent
15783 Note: the above rules apply to recent releases of GNAT 5.
15784 In GNAT 3, there are more severe restrictions on larger components.
15785 For non-primitive types, including packed arrays with a size greater than
15786 64 bits, component clauses must respect the alignment requirement of the
15787 type, in particular, always starting on a byte boundary, and the length
15788 must be a multiple of the storage unit.
15789
15790 @node Handling of Records with Holes
15791 @section Handling of Records with Holes
15792 @cindex Handling of Records with Holes
15793
15794 As a result of alignment considerations, records may contain "holes"
15795 or gaps
15796 which do not correspond to the data bits of any of the components.
15797 Record representation clauses can also result in holes in records.
15798
15799 GNAT does not attempt to clear these holes, so in record objects,
15800 they should be considered to hold undefined rubbish. The generated
15801 equality routine just tests components so does not access these
15802 undefined bits, and assignment and copy operations may or may not
15803 preserve the contents of these holes (for assignments, the holes
15804 in the target will in practice contain either the bits that are
15805 present in the holes in the source, or the bits that were present
15806 in the target before the assignment).
15807
15808 If it is necessary to ensure that holes in records have all zero
15809 bits, then record objects for which this initialization is desired
15810 should be explicitly set to all zero values using Unchecked_Conversion
15811 or address overlays. For example
15812
15813 @smallexample @c ada
15814 type HRec is record
15815 C : Character;
15816 I : Integer;
15817 end record;
15818 @end smallexample
15819
15820 @noindent
15821 On typical machines, integers need to be aligned on a four-byte
15822 boundary, resulting in three bytes of undefined rubbish following
15823 the 8-bit field for C. To ensure that the hole in a variable of
15824 type HRec is set to all zero bits,
15825 you could for example do:
15826
15827 @smallexample @c ada
15828 type Base is record
15829 Dummy1, Dummy2 : Integer := 0;
15830 end record;
15831
15832 BaseVar : Base;
15833 RealVar : Hrec;
15834 for RealVar'Address use BaseVar'Address;
15835 @end smallexample
15836
15837 @noindent
15838 Now the 8-bytes of the value of RealVar start out containing all zero
15839 bits. A safer approach is to just define dummy fields, avoiding the
15840 holes, as in:
15841
15842 @smallexample @c ada
15843 type HRec is record
15844 C : Character;
15845 Dummy1 : Short_Short_Integer := 0;
15846 Dummy2 : Short_Short_Integer := 0;
15847 Dummy3 : Short_Short_Integer := 0;
15848 I : Integer;
15849 end record;
15850 @end smallexample
15851
15852 @noindent
15853 And to make absolutely sure that the intent of this is followed, you
15854 can use representation clauses:
15855
15856 @smallexample @c ada
15857 for Hrec use record
15858 C at 0 range 0 .. 7;
15859 Dummy1 at 1 range 0 .. 7;
15860 Dummy2 at 2 range 0 .. 7;
15861 Dummy3 at 3 range 0 .. 7;
15862 I at 4 range 0 .. 31;
15863 end record;
15864 for Hrec'Size use 64;
15865 @end smallexample
15866
15867 @node Enumeration Clauses
15868 @section Enumeration Clauses
15869
15870 The only restriction on enumeration clauses is that the range of values
15871 must be representable. For the signed case, if one or more of the
15872 representation values are negative, all values must be in the range:
15873
15874 @smallexample @c ada
15875 System.Min_Int .. System.Max_Int
15876 @end smallexample
15877
15878 @noindent
15879 For the unsigned case, where all values are nonnegative, the values must
15880 be in the range:
15881
15882 @smallexample @c ada
15883 0 .. System.Max_Binary_Modulus;
15884 @end smallexample
15885
15886 @noindent
15887 A @emph{confirming} representation clause is one in which the values range
15888 from 0 in sequence, i.e.@: a clause that confirms the default representation
15889 for an enumeration type.
15890 Such a confirming representation
15891 is permitted by these rules, and is specially recognized by the compiler so
15892 that no extra overhead results from the use of such a clause.
15893
15894 If an array has an index type which is an enumeration type to which an
15895 enumeration clause has been applied, then the array is stored in a compact
15896 manner. Consider the declarations:
15897
15898 @smallexample @c ada
15899 type r is (A, B, C);
15900 for r use (A => 1, B => 5, C => 10);
15901 type t is array (r) of Character;
15902 @end smallexample
15903
15904 @noindent
15905 The array type t corresponds to a vector with exactly three elements and
15906 has a default size equal to @code{3*Character'Size}. This ensures efficient
15907 use of space, but means that accesses to elements of the array will incur
15908 the overhead of converting representation values to the corresponding
15909 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
15910
15911 @node Address Clauses
15912 @section Address Clauses
15913 @cindex Address Clause
15914
15915 The reference manual allows a general restriction on representation clauses,
15916 as found in RM 13.1(22):
15917
15918 @quotation
15919 An implementation need not support representation
15920 items containing nonstatic expressions, except that
15921 an implementation should support a representation item
15922 for a given entity if each nonstatic expression in the
15923 representation item is a name that statically denotes
15924 a constant declared before the entity.
15925 @end quotation
15926
15927 @noindent
15928 In practice this is applicable only to address clauses, since this is the
15929 only case in which a non-static expression is permitted by the syntax. As
15930 the AARM notes in sections 13.1 (22.a-22.h):
15931
15932 @display
15933 22.a Reason: This is to avoid the following sort of thing:
15934
15935 22.b X : Integer := F(@dots{});
15936 Y : Address := G(@dots{});
15937 for X'Address use Y;
15938
15939 22.c In the above, we have to evaluate the
15940 initialization expression for X before we
15941 know where to put the result. This seems
15942 like an unreasonable implementation burden.
15943
15944 22.d The above code should instead be written
15945 like this:
15946
15947 22.e Y : constant Address := G(@dots{});
15948 X : Integer := F(@dots{});
15949 for X'Address use Y;
15950
15951 22.f This allows the expression ``Y'' to be safely
15952 evaluated before X is created.
15953
15954 22.g The constant could be a formal parameter of mode in.
15955
15956 22.h An implementation can support other nonstatic
15957 expressions if it wants to. Expressions of type
15958 Address are hardly ever static, but their value
15959 might be known at compile time anyway in many
15960 cases.
15961 @end display
15962
15963 @noindent
15964 GNAT does indeed permit many additional cases of non-static expressions. In
15965 particular, if the type involved is elementary there are no restrictions
15966 (since in this case, holding a temporary copy of the initialization value,
15967 if one is present, is inexpensive). In addition, if there is no implicit or
15968 explicit initialization, then there are no restrictions. GNAT will reject
15969 only the case where all three of these conditions hold:
15970
15971 @itemize @bullet
15972
15973 @item
15974 The type of the item is non-elementary (e.g.@: a record or array).
15975
15976 @item
15977 There is explicit or implicit initialization required for the object.
15978 Note that access values are always implicitly initialized.
15979
15980 @item
15981 The address value is non-static. Here GNAT is more permissive than the
15982 RM, and allows the address value to be the address of a previously declared
15983 stand-alone variable, as long as it does not itself have an address clause.
15984
15985 @smallexample @c ada
15986 Anchor : Some_Initialized_Type;
15987 Overlay : Some_Initialized_Type;
15988 for Overlay'Address use Anchor'Address;
15989 @end smallexample
15990
15991 @noindent
15992 However, the prefix of the address clause cannot be an array component, or
15993 a component of a discriminated record.
15994
15995 @end itemize
15996
15997 @noindent
15998 As noted above in section 22.h, address values are typically non-static. In
15999 particular the To_Address function, even if applied to a literal value, is
16000 a non-static function call. To avoid this minor annoyance, GNAT provides
16001 the implementation defined attribute 'To_Address. The following two
16002 expressions have identical values:
16003
16004 @findex Attribute
16005 @findex To_Address
16006 @smallexample @c ada
16007 To_Address (16#1234_0000#)
16008 System'To_Address (16#1234_0000#);
16009 @end smallexample
16010
16011 @noindent
16012 except that the second form is considered to be a static expression, and
16013 thus when used as an address clause value is always permitted.
16014
16015 @noindent
16016 Additionally, GNAT treats as static an address clause that is an
16017 unchecked_conversion of a static integer value. This simplifies the porting
16018 of legacy code, and provides a portable equivalent to the GNAT attribute
16019 @code{To_Address}.
16020
16021 Another issue with address clauses is the interaction with alignment
16022 requirements. When an address clause is given for an object, the address
16023 value must be consistent with the alignment of the object (which is usually
16024 the same as the alignment of the type of the object). If an address clause
16025 is given that specifies an inappropriately aligned address value, then the
16026 program execution is erroneous.
16027
16028 Since this source of erroneous behavior can have unfortunate effects, GNAT
16029 checks (at compile time if possible, generating a warning, or at execution
16030 time with a run-time check) that the alignment is appropriate. If the
16031 run-time check fails, then @code{Program_Error} is raised. This run-time
16032 check is suppressed if range checks are suppressed, or if the special GNAT
16033 check Alignment_Check is suppressed, or if
16034 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
16035
16036 Finally, GNAT does not permit overlaying of objects of controlled types or
16037 composite types containing a controlled component. In most cases, the compiler
16038 can detect an attempt at such overlays and will generate a warning at compile
16039 time and a Program_Error exception at run time.
16040
16041 @findex Export
16042 An address clause cannot be given for an exported object. More
16043 understandably the real restriction is that objects with an address
16044 clause cannot be exported. This is because such variables are not
16045 defined by the Ada program, so there is no external object to export.
16046
16047 @findex Import
16048 It is permissible to give an address clause and a pragma Import for the
16049 same object. In this case, the variable is not really defined by the
16050 Ada program, so there is no external symbol to be linked. The link name
16051 and the external name are ignored in this case. The reason that we allow this
16052 combination is that it provides a useful idiom to avoid unwanted
16053 initializations on objects with address clauses.
16054
16055 When an address clause is given for an object that has implicit or
16056 explicit initialization, then by default initialization takes place. This
16057 means that the effect of the object declaration is to overwrite the
16058 memory at the specified address. This is almost always not what the
16059 programmer wants, so GNAT will output a warning:
16060
16061 @smallexample
16062 with System;
16063 package G is
16064 type R is record
16065 M : Integer := 0;
16066 end record;
16067
16068 Ext : R;
16069 for Ext'Address use System'To_Address (16#1234_1234#);
16070 |
16071 >>> warning: implicit initialization of "Ext" may
16072 modify overlaid storage
16073 >>> warning: use pragma Import for "Ext" to suppress
16074 initialization (RM B(24))
16075
16076 end G;
16077 @end smallexample
16078
16079 @noindent
16080 As indicated by the warning message, the solution is to use a (dummy) pragma
16081 Import to suppress this initialization. The pragma tell the compiler that the
16082 object is declared and initialized elsewhere. The following package compiles
16083 without warnings (and the initialization is suppressed):
16084
16085 @smallexample @c ada
16086 with System;
16087 package G is
16088 type R is record
16089 M : Integer := 0;
16090 end record;
16091
16092 Ext : R;
16093 for Ext'Address use System'To_Address (16#1234_1234#);
16094 pragma Import (Ada, Ext);
16095 end G;
16096 @end smallexample
16097
16098 @noindent
16099 A final issue with address clauses involves their use for overlaying
16100 variables, as in the following example:
16101 @cindex Overlaying of objects
16102
16103 @smallexample @c ada
16104 A : Integer;
16105 B : Integer;
16106 for B'Address use A'Address;
16107 @end smallexample
16108
16109 @noindent
16110 or alternatively, using the form recommended by the RM:
16111
16112 @smallexample @c ada
16113 A : Integer;
16114 Addr : constant Address := A'Address;
16115 B : Integer;
16116 for B'Address use Addr;
16117 @end smallexample
16118
16119 @noindent
16120 In both of these cases, @code{A}
16121 and @code{B} become aliased to one another via the
16122 address clause. This use of address clauses to overlay
16123 variables, achieving an effect similar to unchecked
16124 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
16125 the effect is implementation defined. Furthermore, the
16126 Ada RM specifically recommends that in a situation
16127 like this, @code{B} should be subject to the following
16128 implementation advice (RM 13.3(19)):
16129
16130 @quotation
16131 19 If the Address of an object is specified, or it is imported
16132 or exported, then the implementation should not perform
16133 optimizations based on assumptions of no aliases.
16134 @end quotation
16135
16136 @noindent
16137 GNAT follows this recommendation, and goes further by also applying
16138 this recommendation to the overlaid variable (@code{A}
16139 in the above example) in this case. This means that the overlay
16140 works "as expected", in that a modification to one of the variables
16141 will affect the value of the other.
16142
16143 Note that when address clause overlays are used in this way, there is an
16144 issue of unintentional initialization, as shown by this example:
16145
16146 @smallexample @c ada
16147 package Overwrite_Record is
16148 type R is record
16149 A : Character := 'C';
16150 B : Character := 'A';
16151 end record;
16152 X : Short_Integer := 3;
16153 Y : R;
16154 for Y'Address use X'Address;
16155 |
16156 >>> warning: default initialization of "Y" may
16157 modify "X", use pragma Import for "Y" to
16158 suppress initialization (RM B.1(24))
16159
16160 end Overwrite_Record;
16161 @end smallexample
16162
16163 @noindent
16164 Here the default initialization of @code{Y} will clobber the value
16165 of @code{X}, which justifies the warning. The warning notes that
16166 this effect can be eliminated by adding a @code{pragma Import}
16167 which suppresses the initialization:
16168
16169 @smallexample @c ada
16170 package Overwrite_Record is
16171 type R is record
16172 A : Character := 'C';
16173 B : Character := 'A';
16174 end record;
16175 X : Short_Integer := 3;
16176 Y : R;
16177 for Y'Address use X'Address;
16178 pragma Import (Ada, Y);
16179 end Overwrite_Record;
16180 @end smallexample
16181
16182 @noindent
16183 Note that the use of @code{pragma Initialize_Scalars} may cause variables to
16184 be initialized when they would not otherwise have been in the absence
16185 of the use of this pragma. This may cause an overlay to have this
16186 unintended clobbering effect. The compiler avoids this for scalar
16187 types, but not for composite objects (where in general the effect
16188 of @code{Initialize_Scalars} is part of the initialization routine
16189 for the composite object:
16190
16191 @smallexample @c ada
16192 pragma Initialize_Scalars;
16193 with Ada.Text_IO; use Ada.Text_IO;
16194 procedure Overwrite_Array is
16195 type Arr is array (1 .. 5) of Integer;
16196 X : Arr := (others => 1);
16197 A : Arr;
16198 for A'Address use X'Address;
16199 |
16200 >>> warning: default initialization of "A" may
16201 modify "X", use pragma Import for "A" to
16202 suppress initialization (RM B.1(24))
16203
16204 begin
16205 if X /= Arr'(others => 1) then
16206 Put_Line ("X was clobbered");
16207 else
16208 Put_Line ("X was not clobbered");
16209 end if;
16210 end Overwrite_Array;
16211 @end smallexample
16212
16213 @noindent
16214 The above program generates the warning as shown, and at execution
16215 time, prints @code{X was clobbered}. If the @code{pragma Import} is
16216 added as suggested:
16217
16218 @smallexample @c ada
16219 pragma Initialize_Scalars;
16220 with Ada.Text_IO; use Ada.Text_IO;
16221 procedure Overwrite_Array is
16222 type Arr is array (1 .. 5) of Integer;
16223 X : Arr := (others => 1);
16224 A : Arr;
16225 for A'Address use X'Address;
16226 pragma Import (Ada, A);
16227 begin
16228 if X /= Arr'(others => 1) then
16229 Put_Line ("X was clobbered");
16230 else
16231 Put_Line ("X was not clobbered");
16232 end if;
16233 end Overwrite_Array;
16234 @end smallexample
16235
16236 @noindent
16237 then the program compiles without the warning and when run will generate
16238 the output @code{X was not clobbered}.
16239
16240 @node Effect of Convention on Representation
16241 @section Effect of Convention on Representation
16242 @cindex Convention, effect on representation
16243
16244 @noindent
16245 Normally the specification of a foreign language convention for a type or
16246 an object has no effect on the chosen representation. In particular, the
16247 representation chosen for data in GNAT generally meets the standard system
16248 conventions, and for example records are laid out in a manner that is
16249 consistent with C@. This means that specifying convention C (for example)
16250 has no effect.
16251
16252 There are four exceptions to this general rule:
16253
16254 @itemize @bullet
16255
16256 @item Convention Fortran and array subtypes
16257 If pragma Convention Fortran is specified for an array subtype, then in
16258 accordance with the implementation advice in section 3.6.2(11) of the
16259 Ada Reference Manual, the array will be stored in a Fortran-compatible
16260 column-major manner, instead of the normal default row-major order.
16261
16262 @item Convention C and enumeration types
16263 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
16264 to accommodate all values of the type. For example, for the enumeration
16265 type declared by:
16266
16267 @smallexample @c ada
16268 type Color is (Red, Green, Blue);
16269 @end smallexample
16270
16271 @noindent
16272 8 bits is sufficient to store all values of the type, so by default, objects
16273 of type @code{Color} will be represented using 8 bits. However, normal C
16274 convention is to use 32 bits for all enum values in C, since enum values
16275 are essentially of type int. If pragma @code{Convention C} is specified for an
16276 Ada enumeration type, then the size is modified as necessary (usually to
16277 32 bits) to be consistent with the C convention for enum values.
16278
16279 Note that this treatment applies only to types. If Convention C is given for
16280 an enumeration object, where the enumeration type is not Convention C, then
16281 Object_Size bits are allocated. For example, for a normal enumeration type,
16282 with less than 256 elements, only 8 bits will be allocated for the object.
16283 Since this may be a surprise in terms of what C expects, GNAT will issue a
16284 warning in this situation. The warning can be suppressed by giving an explicit
16285 size clause specifying the desired size.
16286
16287 @item Convention C/Fortran and Boolean types
16288 In C, the usual convention for boolean values, that is values used for
16289 conditions, is that zero represents false, and nonzero values represent
16290 true. In Ada, the normal convention is that two specific values, typically
16291 0/1, are used to represent false/true respectively.
16292
16293 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
16294 value represents true).
16295
16296 To accommodate the Fortran and C conventions, if a pragma Convention specifies
16297 C or Fortran convention for a derived Boolean, as in the following example:
16298
16299 @smallexample @c ada
16300 type C_Switch is new Boolean;
16301 pragma Convention (C, C_Switch);
16302 @end smallexample
16303
16304 @noindent
16305 then the GNAT generated code will treat any nonzero value as true. For truth
16306 values generated by GNAT, the conventional value 1 will be used for True, but
16307 when one of these values is read, any nonzero value is treated as True.
16308
16309 @item Access types on OpenVMS
16310 For 64-bit OpenVMS systems, access types (other than those for unconstrained
16311 arrays) are 64-bits long. An exception to this rule is for the case of
16312 C-convention access types where there is no explicit size clause present (or
16313 inherited for derived types). In this case, GNAT chooses to make these
16314 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
16315 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
16316
16317 @end itemize
16318
16319 @node Conventions and Anonymous Access Types
16320 @section Conventions and Anonymous Access Types
16321 @cindex Anonymous access types
16322 @cindex Convention for anonymous access types
16323
16324 The RM is not entirely clear on convention handling in a number of cases,
16325 and in particular, it is not clear on the convention to be given to
16326 anonymous access types in general, and in particular what is to be
16327 done for the case of anonymous access-to-subprogram.
16328
16329 In GNAT, we decide that if an explicit Convention is applied
16330 to an object or component, and its type is such an anonymous type,
16331 then the convention will apply to this anonymous type as well. This
16332 seems to make sense since it is anomolous in any case to have a
16333 different convention for an object and its type, and there is clearly
16334 no way to explicitly specify a convention for an anonymous type, since
16335 it doesn't have a name to specify!
16336
16337 Furthermore, we decide that if a convention is applied to a record type,
16338 then this convention is inherited by any of its components that are of an
16339 anonymous access type which do not have an explicitly specified convention.
16340
16341 The following program shows these conventions in action:
16342
16343 @smallexample @c ada
16344 package ConvComp is
16345 type Foo is range 1 .. 10;
16346 type T1 is record
16347 A : access function (X : Foo) return Integer;
16348 B : Integer;
16349 end record;
16350 pragma Convention (C, T1);
16351
16352 type T2 is record
16353 A : access function (X : Foo) return Integer;
16354 pragma Convention (C, A);
16355 B : Integer;
16356 end record;
16357 pragma Convention (COBOL, T2);
16358
16359 type T3 is record
16360 A : access function (X : Foo) return Integer;
16361 pragma Convention (COBOL, A);
16362 B : Integer;
16363 end record;
16364 pragma Convention (C, T3);
16365
16366 type T4 is record
16367 A : access function (X : Foo) return Integer;
16368 B : Integer;
16369 end record;
16370 pragma Convention (COBOL, T4);
16371
16372 function F (X : Foo) return Integer;
16373 pragma Convention (C, F);
16374
16375 function F (X : Foo) return Integer is (13);
16376
16377 TV1 : T1 := (F'Access, 12); -- OK
16378 TV2 : T2 := (F'Access, 13); -- OK
16379
16380 TV3 : T3 := (F'Access, 13); -- ERROR
16381 |
16382 >>> subprogram "F" has wrong convention
16383 >>> does not match access to subprogram declared at line 17
16384 38. TV4 : T4 := (F'Access, 13); -- ERROR
16385 |
16386 >>> subprogram "F" has wrong convention
16387 >>> does not match access to subprogram declared at line 24
16388 39. end ConvComp;
16389 @end smallexample
16390
16391 @node Determining the Representations chosen by GNAT
16392 @section Determining the Representations chosen by GNAT
16393 @cindex Representation, determination of
16394 @cindex @option{-gnatR} switch
16395
16396 @noindent
16397 Although the descriptions in this section are intended to be complete, it is
16398 often easier to simply experiment to see what GNAT accepts and what the
16399 effect is on the layout of types and objects.
16400
16401 As required by the Ada RM, if a representation clause is not accepted, then
16402 it must be rejected as illegal by the compiler. However, when a
16403 representation clause or pragma is accepted, there can still be questions
16404 of what the compiler actually does. For example, if a partial record
16405 representation clause specifies the location of some components and not
16406 others, then where are the non-specified components placed? Or if pragma
16407 @code{Pack} is used on a record, then exactly where are the resulting
16408 fields placed? The section on pragma @code{Pack} in this chapter can be
16409 used to answer the second question, but it is often easier to just see
16410 what the compiler does.
16411
16412 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
16413 with this option, then the compiler will output information on the actual
16414 representations chosen, in a format similar to source representation
16415 clauses. For example, if we compile the package:
16416
16417 @smallexample @c ada
16418 package q is
16419 type r (x : boolean) is tagged record
16420 case x is
16421 when True => S : String (1 .. 100);
16422 when False => null;
16423 end case;
16424 end record;
16425
16426 type r2 is new r (false) with record
16427 y2 : integer;
16428 end record;
16429
16430 for r2 use record
16431 y2 at 16 range 0 .. 31;
16432 end record;
16433
16434 type x is record
16435 y : character;
16436 end record;
16437
16438 type x1 is array (1 .. 10) of x;
16439 for x1'component_size use 11;
16440
16441 type ia is access integer;
16442
16443 type Rb1 is array (1 .. 13) of Boolean;
16444 pragma Pack (rb1);
16445
16446 type Rb2 is array (1 .. 65) of Boolean;
16447 pragma Pack (rb2);
16448
16449 type x2 is record
16450 l1 : Boolean;
16451 l2 : Duration;
16452 l3 : Float;
16453 l4 : Boolean;
16454 l5 : Rb1;
16455 l6 : Rb2;
16456 end record;
16457 pragma Pack (x2);
16458 end q;
16459 @end smallexample
16460
16461 @noindent
16462 using the switch @option{-gnatR} we obtain the following output:
16463
16464 @smallexample
16465 Representation information for unit q
16466 -------------------------------------
16467
16468 for r'Size use ??;
16469 for r'Alignment use 4;
16470 for r use record
16471 x at 4 range 0 .. 7;
16472 _tag at 0 range 0 .. 31;
16473 s at 5 range 0 .. 799;
16474 end record;
16475
16476 for r2'Size use 160;
16477 for r2'Alignment use 4;
16478 for r2 use record
16479 x at 4 range 0 .. 7;
16480 _tag at 0 range 0 .. 31;
16481 _parent at 0 range 0 .. 63;
16482 y2 at 16 range 0 .. 31;
16483 end record;
16484
16485 for x'Size use 8;
16486 for x'Alignment use 1;
16487 for x use record
16488 y at 0 range 0 .. 7;
16489 end record;
16490
16491 for x1'Size use 112;
16492 for x1'Alignment use 1;
16493 for x1'Component_Size use 11;
16494
16495 for rb1'Size use 13;
16496 for rb1'Alignment use 2;
16497 for rb1'Component_Size use 1;
16498
16499 for rb2'Size use 72;
16500 for rb2'Alignment use 1;
16501 for rb2'Component_Size use 1;
16502
16503 for x2'Size use 224;
16504 for x2'Alignment use 4;
16505 for x2 use record
16506 l1 at 0 range 0 .. 0;
16507 l2 at 0 range 1 .. 64;
16508 l3 at 12 range 0 .. 31;
16509 l4 at 16 range 0 .. 0;
16510 l5 at 16 range 1 .. 13;
16511 l6 at 18 range 0 .. 71;
16512 end record;
16513 @end smallexample
16514
16515 @noindent
16516 The Size values are actually the Object_Size, i.e.@: the default size that
16517 will be allocated for objects of the type.
16518 The ?? size for type r indicates that we have a variant record, and the
16519 actual size of objects will depend on the discriminant value.
16520
16521 The Alignment values show the actual alignment chosen by the compiler
16522 for each record or array type.
16523
16524 The record representation clause for type r shows where all fields
16525 are placed, including the compiler generated tag field (whose location
16526 cannot be controlled by the programmer).
16527
16528 The record representation clause for the type extension r2 shows all the
16529 fields present, including the parent field, which is a copy of the fields
16530 of the parent type of r2, i.e.@: r1.
16531
16532 The component size and size clauses for types rb1 and rb2 show
16533 the exact effect of pragma @code{Pack} on these arrays, and the record
16534 representation clause for type x2 shows how pragma @code{Pack} affects
16535 this record type.
16536
16537 In some cases, it may be useful to cut and paste the representation clauses
16538 generated by the compiler into the original source to fix and guarantee
16539 the actual representation to be used.
16540
16541 @node Standard Library Routines
16542 @chapter Standard Library Routines
16543
16544 @noindent
16545 The Ada Reference Manual contains in Annex A a full description of an
16546 extensive set of standard library routines that can be used in any Ada
16547 program, and which must be provided by all Ada compilers. They are
16548 analogous to the standard C library used by C programs.
16549
16550 GNAT implements all of the facilities described in annex A, and for most
16551 purposes the description in the Ada Reference Manual, or appropriate Ada
16552 text book, will be sufficient for making use of these facilities.
16553
16554 In the case of the input-output facilities,
16555 @xref{The Implementation of Standard I/O},
16556 gives details on exactly how GNAT interfaces to the
16557 file system. For the remaining packages, the Ada Reference Manual
16558 should be sufficient. The following is a list of the packages included,
16559 together with a brief description of the functionality that is provided.
16560
16561 For completeness, references are included to other predefined library
16562 routines defined in other sections of the Ada Reference Manual (these are
16563 cross-indexed from Annex A). For further details see the relevant
16564 package declarations in the run-time library. In particular, a few units
16565 are not implemented, as marked by the presence of pragma Unimplemented_Unit,
16566 and in this case the package declaration contains comments explaining why
16567 the unit is not implemented.
16568
16569 @table @code
16570 @item Ada (A.2)
16571 This is a parent package for all the standard library packages. It is
16572 usually included implicitly in your program, and itself contains no
16573 useful data or routines.
16574
16575 @item Ada.Assertions (11.4.2)
16576 @code{Assertions} provides the @code{Assert} subprograms, and also
16577 the declaration of the @code{Assertion_Error} exception.
16578
16579 @item Ada.Asynchronous_Task_Control (D.11)
16580 @code{Asynchronous_Task_Control} provides low level facilities for task
16581 synchronization. It is typically not implemented. See package spec for details.
16582
16583 @item Ada.Calendar (9.6)
16584 @code{Calendar} provides time of day access, and routines for
16585 manipulating times and durations.
16586
16587 @item Ada.Calendar.Arithmetic (9.6.1)
16588 This package provides additional arithmetic
16589 operations for @code{Calendar}.
16590
16591 @item Ada.Calendar.Formatting (9.6.1)
16592 This package provides formatting operations for @code{Calendar}.
16593
16594 @item Ada.Calendar.Time_Zones (9.6.1)
16595 This package provides additional @code{Calendar} facilities
16596 for handling time zones.
16597
16598 @item Ada.Characters (A.3.1)
16599 This is a dummy parent package that contains no useful entities
16600
16601 @item Ada.Characters.Conversions (A.3.2)
16602 This package provides character conversion functions.
16603
16604 @item Ada.Characters.Handling (A.3.2)
16605 This package provides some basic character handling capabilities,
16606 including classification functions for classes of characters (e.g.@: test
16607 for letters, or digits).
16608
16609 @item Ada.Characters.Latin_1 (A.3.3)
16610 This package includes a complete set of definitions of the characters
16611 that appear in type CHARACTER@. It is useful for writing programs that
16612 will run in international environments. For example, if you want an
16613 upper case E with an acute accent in a string, it is often better to use
16614 the definition of @code{UC_E_Acute} in this package. Then your program
16615 will print in an understandable manner even if your environment does not
16616 support these extended characters.
16617
16618 @item Ada.Command_Line (A.15)
16619 This package provides access to the command line parameters and the name
16620 of the current program (analogous to the use of @code{argc} and @code{argv}
16621 in C), and also allows the exit status for the program to be set in a
16622 system-independent manner.
16623
16624 @item Ada.Complex_Text_IO (G.1.3)
16625 This package provides text input and output of complex numbers.
16626
16627 @item Ada.Containers (A.18.1)
16628 A top level package providing a few basic definitions used by all the
16629 following specific child packages that provide specific kinds of
16630 containers.
16631
16632 @item Ada.Containers.Bounded_Priority_Queues (A.18.31)
16633
16634 @item Ada.Containers.Bounded_Synchronized_Queues (A.18.29)
16635
16636 @item Ada.Containers.Doubly_Linked_Lists (A.18.3)
16637
16638 @item Ada.Containers.Generic_Array_Sort (A.18.26)
16639
16640 @item Ada.Containers.Generic_Constrained_Array_Sort (A.18.26)
16641
16642 @item Ada.Containers.Generic_Sort (A.18.26)
16643
16644 @item Ada.Containers.Hashed_Maps (A.18.5)
16645
16646 @item Ada.Containers.Hashed_Sets (A.18.8)
16647
16648 @item Ada.Containers.Indefinite_Doubly_Linked_Lists (A.18.12)
16649
16650 @item Ada.Containers.Indefinite_Hashed_Maps (A.18.13)
16651
16652 @item Ada.Containers.Indefinite_Hashed_Sets (A.18.15)
16653
16654 @item Ada.Containers.Indefinite_Holders (A.18.18)
16655
16656 @item Ada.Containers.Indefinite_Multiway_Trees (A.18.17)
16657
16658 @item Ada.Containers.Indefinite_Ordered_Maps (A.18.14)
16659
16660 @item Ada.Containers.Indefinite_Ordered_Sets (A.18.16)
16661
16662 @item Ada.Containers.Indefinite_Vectors (A.18.11)
16663
16664 @item Ada.Containers.Multiway_Trees (A.18.10)
16665
16666 @item Ada.Containers.Ordered_Maps (A.18.6)
16667
16668 @item Ada.Containers.Ordered_Sets (A.18.9)
16669
16670 @item Ada.Containers.Synchronized_Queue_Interfaces (A.18.27)
16671
16672 @item Ada.Containers.Unbounded_Priority_Queues (A.18.30)
16673
16674 @item Ada.Containers.Unbounded_Synchronized_Queues (A.18.28)
16675
16676 @item Ada.Containers.Vectors (A.18.2)
16677
16678 @item Ada.Directories (A.16)
16679 This package provides operations on directories.
16680
16681 @item Ada.Directories.Hierarchical_File_Names (A.16.1)
16682 This package provides additional directory operations handling
16683 hiearchical file names.
16684
16685 @item Ada.Directories.Information (A.16)
16686 This is an implementation defined package for additional directory
16687 operations, which is not implemented in GNAT.
16688
16689 @item Ada.Decimal (F.2)
16690 This package provides constants describing the range of decimal numbers
16691 implemented, and also a decimal divide routine (analogous to the COBOL
16692 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
16693
16694 @item Ada.Direct_IO (A.8.4)
16695 This package provides input-output using a model of a set of records of
16696 fixed-length, containing an arbitrary definite Ada type, indexed by an
16697 integer record number.
16698
16699 @item Ada.Dispatching (D.2.1)
16700 A parent package containing definitions for task dispatching operations.
16701
16702 @item Ada.Dispatching.EDF (D.2.6)
16703 Not implemented in GNAT.
16704
16705 @item Ada.Dispatching.Non_Preemptive (D.2.4)
16706 Not implemented in GNAT.
16707
16708 @item Ada.Dispatching.Round_Robin (D.2.5)
16709 Not implemented in GNAT.
16710
16711 @item Ada.Dynamic_Priorities (D.5)
16712 This package allows the priorities of a task to be adjusted dynamically
16713 as the task is running.
16714
16715 @item Ada.Environment_Variables (A.17)
16716 This package provides facilities for accessing environment variables.
16717
16718 @item Ada.Exceptions (11.4.1)
16719 This package provides additional information on exceptions, and also
16720 contains facilities for treating exceptions as data objects, and raising
16721 exceptions with associated messages.
16722
16723 @item Ada.Execution_Time (D.14)
16724 Not implemented in GNAT.
16725
16726 @item Ada.Execution_Time.Group_Budgets (D.14.2)
16727 Not implemented in GNAT.
16728
16729 @item Ada.Execution_Time.Timers (D.14.1)'
16730 Not implemented in GNAT.
16731
16732 @item Ada.Finalization (7.6)
16733 This package contains the declarations and subprograms to support the
16734 use of controlled types, providing for automatic initialization and
16735 finalization (analogous to the constructors and destructors of C++).
16736
16737 @item Ada.Float_Text_IO (A.10.9)
16738 A library level instantiation of Text_IO.Float_IO for type Float.
16739
16740 @item Ada.Float_Wide_Text_IO (A.10.9)
16741 A library level instantiation of Wide_Text_IO.Float_IO for type Float.
16742
16743 @item Ada.Float_Wide_Wide_Text_IO (A.10.9)
16744 A library level instantiation of Wide_Wide_Text_IO.Float_IO for type Float.
16745
16746 @item Ada.Integer_Text_IO (A.10.9)
16747 A library level instantiation of Text_IO.Integer_IO for type Integer.
16748
16749 @item Ada.Integer_Wide_Text_IO (A.10.9)
16750 A library level instantiation of Wide_Text_IO.Integer_IO for type Integer.
16751
16752 @item Ada.Integer_Wide_Wide_Text_IO (A.10.9)
16753 A library level instantiation of Wide_Wide_Text_IO.Integer_IO for type Integer.
16754
16755 @item Ada.Interrupts (C.3.2)
16756 This package provides facilities for interfacing to interrupts, which
16757 includes the set of signals or conditions that can be raised and
16758 recognized as interrupts.
16759
16760 @item Ada.Interrupts.Names (C.3.2)
16761 This package provides the set of interrupt names (actually signal
16762 or condition names) that can be handled by GNAT@.
16763
16764 @item Ada.IO_Exceptions (A.13)
16765 This package defines the set of exceptions that can be raised by use of
16766 the standard IO packages.
16767
16768 @item Ada.Iterator_Interfaces (5.5.1)
16769 This package provides a generic interface to generalized iterators.
16770
16771 @item Ada.Locales (A.19)
16772 This package provides declarations providing information (Language
16773 and Country) about the current locale.
16774
16775 @item Ada.Numerics
16776 This package contains some standard constants and exceptions used
16777 throughout the numerics packages. Note that the constants pi and e are
16778 defined here, and it is better to use these definitions than rolling
16779 your own.
16780
16781 @item Ada.Numerics.Complex_Arrays (G.3.2)
16782 Provides operations on arrays of complex numbers.
16783
16784 @item Ada.Numerics.Complex_Elementary_Functions
16785 Provides the implementation of standard elementary functions (such as
16786 log and trigonometric functions) operating on complex numbers using the
16787 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
16788 created by the package @code{Numerics.Complex_Types}.
16789
16790 @item Ada.Numerics.Complex_Types
16791 This is a predefined instantiation of
16792 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
16793 build the type @code{Complex} and @code{Imaginary}.
16794
16795 @item Ada.Numerics.Discrete_Random
16796 This generic package provides a random number generator suitable for generating
16797 uniformly distributed values of a specified discrete subtype.
16798
16799 @item Ada.Numerics.Float_Random
16800 This package provides a random number generator suitable for generating
16801 uniformly distributed floating point values in the unit interval.
16802
16803 @item Ada.Numerics.Generic_Complex_Elementary_Functions
16804 This is a generic version of the package that provides the
16805 implementation of standard elementary functions (such as log and
16806 trigonometric functions) for an arbitrary complex type.
16807
16808 The following predefined instantiations of this package are provided:
16809
16810 @table @code
16811 @item Short_Float
16812 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
16813 @item Float
16814 @code{Ada.Numerics.Complex_Elementary_Functions}
16815 @item Long_Float
16816 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
16817 @end table
16818
16819 @item Ada.Numerics.Generic_Complex_Types
16820 This is a generic package that allows the creation of complex types,
16821 with associated complex arithmetic operations.
16822
16823 The following predefined instantiations of this package exist
16824 @table @code
16825 @item Short_Float
16826 @code{Ada.Numerics.Short_Complex_Complex_Types}
16827 @item Float
16828 @code{Ada.Numerics.Complex_Complex_Types}
16829 @item Long_Float
16830 @code{Ada.Numerics.Long_Complex_Complex_Types}
16831 @end table
16832
16833 @item Ada.Numerics.Generic_Elementary_Functions
16834 This is a generic package that provides the implementation of standard
16835 elementary functions (such as log an trigonometric functions) for an
16836 arbitrary float type.
16837
16838 The following predefined instantiations of this package exist
16839
16840 @table @code
16841 @item Short_Float
16842 @code{Ada.Numerics.Short_Elementary_Functions}
16843 @item Float
16844 @code{Ada.Numerics.Elementary_Functions}
16845 @item Long_Float
16846 @code{Ada.Numerics.Long_Elementary_Functions}
16847 @end table
16848
16849 @item Ada.Numerics.Generic_Real_Arrays (G.3.1)
16850 Generic operations on arrays of reals
16851
16852 @item Ada.Numerics.Real_Arrays (G.3.1)
16853 Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).
16854
16855 @item Ada.Real_Time (D.8)
16856 This package provides facilities similar to those of @code{Calendar}, but
16857 operating with a finer clock suitable for real time control. Note that
16858 annex D requires that there be no backward clock jumps, and GNAT generally
16859 guarantees this behavior, but of course if the external clock on which
16860 the GNAT runtime depends is deliberately reset by some external event,
16861 then such a backward jump may occur.
16862
16863 @item Ada.Real_Time.Timing_Events (D.15)
16864 Not implemented in GNAT.
16865
16866 @item Ada.Sequential_IO (A.8.1)
16867 This package provides input-output facilities for sequential files,
16868 which can contain a sequence of values of a single type, which can be
16869 any Ada type, including indefinite (unconstrained) types.
16870
16871 @item Ada.Storage_IO (A.9)
16872 This package provides a facility for mapping arbitrary Ada types to and
16873 from a storage buffer. It is primarily intended for the creation of new
16874 IO packages.
16875
16876 @item Ada.Streams (13.13.1)
16877 This is a generic package that provides the basic support for the
16878 concept of streams as used by the stream attributes (@code{Input},
16879 @code{Output}, @code{Read} and @code{Write}).
16880
16881 @item Ada.Streams.Stream_IO (A.12.1)
16882 This package is a specialization of the type @code{Streams} defined in
16883 package @code{Streams} together with a set of operations providing
16884 Stream_IO capability. The Stream_IO model permits both random and
16885 sequential access to a file which can contain an arbitrary set of values
16886 of one or more Ada types.
16887
16888 @item Ada.Strings (A.4.1)
16889 This package provides some basic constants used by the string handling
16890 packages.
16891
16892 @item Ada.Strings.Bounded (A.4.4)
16893 This package provides facilities for handling variable length
16894 strings. The bounded model requires a maximum length. It is thus
16895 somewhat more limited than the unbounded model, but avoids the use of
16896 dynamic allocation or finalization.
16897
16898 @item Ada.Strings.Bounded.Equal_Case_Insensitive (A.4.10)
16899 Provides case-insensitive comparisons of bounded strings
16900
16901 @item Ada.Strings.Bounded.Hash (A.4.9)
16902 This package provides a generic hash function for bounded strings
16903
16904 @item Ada.Strings.Bounded.Hash_Case_Insensitive (A.4.9)
16905 This package provides a generic hash function for bounded strings that
16906 converts the string to be hashed to lower case.
16907
16908 @item Ada.Strings.Bounded.Less_Case_Insensitive (A.4.10)
16909 This package provides a comparison function for bounded strings that works
16910 in a case insensitive manner by converting to lower case before the comparison.
16911
16912 @item Ada.Strings.Fixed (A.4.3)
16913 This package provides facilities for handling fixed length strings.
16914
16915 @item Ada.Strings.Fixed.Equal_Case_Insensitive (A.4.10)
16916 This package provides an equality function for fixed strings that compares
16917 the strings after converting both to lower case.
16918
16919 @item Ada.Strings.Fixed.Hash_Case_Insensitive (A.4.9)
16920 This package provides a case insensitive hash function for fixed strings that
16921 converts the string to lower case before computing the hash.
16922
16923 @item Ada.Strings.Fixed.Less_Case_Insensitive (A.4.10)
16924 This package provides a comparison function for fixed strings that works
16925 in a case insensitive manner by converting to lower case before the comparison.
16926
16927 Ada.Strings.Hash (A.4.9)
16928 This package provides a hash function for strings.
16929
16930 Ada.Strings.Hash_Case_Insensitive (A.4.9)
16931 This package provides a hash function for strings that is case insensitive.
16932 The string is converted to lower case before computing the hash.
16933
16934 @item Ada.Strings.Less_Case_Insensitive (A.4.10)
16935 This package provides a comparison function for\strings that works
16936 in a case insensitive manner by converting to lower case before the comparison.
16937
16938 @item Ada.Strings.Maps (A.4.2)
16939 This package provides facilities for handling character mappings and
16940 arbitrarily defined subsets of characters. For instance it is useful in
16941 defining specialized translation tables.
16942
16943 @item Ada.Strings.Maps.Constants (A.4.6)
16944 This package provides a standard set of predefined mappings and
16945 predefined character sets. For example, the standard upper to lower case
16946 conversion table is found in this package. Note that upper to lower case
16947 conversion is non-trivial if you want to take the entire set of
16948 characters, including extended characters like E with an acute accent,
16949 into account. You should use the mappings in this package (rather than
16950 adding 32 yourself) to do case mappings.
16951
16952 @item Ada.Strings.Unbounded (A.4.5)
16953 This package provides facilities for handling variable length
16954 strings. The unbounded model allows arbitrary length strings, but
16955 requires the use of dynamic allocation and finalization.
16956
16957 @item Ada.Strings.Unbounded.Equal_Case_Insensitive (A.4.10)
16958 Provides case-insensitive comparisons of unbounded strings
16959
16960 @item Ada.Strings.Unbounded.Hash (A.4.9)
16961 This package provides a generic hash function for unbounded strings
16962
16963 @item Ada.Strings.Unbounded.Hash_Case_Insensitive (A.4.9)
16964 This package provides a generic hash function for unbounded strings that
16965 converts the string to be hashed to lower case.
16966
16967 @item Ada.Strings.Unbounded.Less_Case_Insensitive (A.4.10)
16968 This package provides a comparison function for unbounded strings that works
16969 in a case insensitive manner by converting to lower case before the comparison.
16970
16971 @item Ada.Strings.UTF_Encoding (A.4.11)
16972 This package provides basic definitions for dealing with UTF-encoded strings.
16973
16974 @item Ada.Strings.UTF_Encoding.Conversions (A.4.11)
16975 This package provides conversion functions for UTF-encoded strings.
16976
16977 @item Ada.Strings.UTF_Encoding.Strings (A.4.11)
16978 @itemx Ada.Strings.UTF_Encoding.Wide_Strings (A.4.11)
16979 @itemx Ada.Strings.UTF_Encoding.Wide_Wide_Strings (A.4.11)
16980 These packages provide facilities for handling UTF encodings for
16981 Strings, Wide_Strings and Wide_Wide_Strings.
16982
16983 @item Ada.Strings.Wide_Bounded (A.4.7)
16984 @itemx Ada.Strings.Wide_Fixed (A.4.7)
16985 @itemx Ada.Strings.Wide_Maps (A.4.7)
16986 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
16987 These packages provide analogous capabilities to the corresponding
16988 packages without @samp{Wide_} in the name, but operate with the types
16989 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
16990 and @code{Character}. Versions of all the child packages are available.
16991
16992 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
16993 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
16994 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
16995 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
16996 These packages provide analogous capabilities to the corresponding
16997 packages without @samp{Wide_} in the name, but operate with the types
16998 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
16999 of @code{String} and @code{Character}.
17000
17001 @item Ada.Synchronous_Barriers (D.10.1)
17002 This package provides facilities for synchronizing tasks at a low level
17003 with barriers.
17004
17005 @item Ada.Synchronous_Task_Control (D.10)
17006 This package provides some standard facilities for controlling task
17007 communication in a synchronous manner.
17008
17009 @item Ada.Synchronous_Task_Control.EDF (D.10)
17010 Not implemented in GNAT.
17011
17012 @item Ada.Tags
17013 This package contains definitions for manipulation of the tags of tagged
17014 values.
17015
17016 @item Ada.Tags.Generic_Dispatching_Constructor (3.9)
17017 This package provides a way of constructing tagged class-wide values given
17018 only the tag value.
17019
17020 @item Ada.Task_Attributes (C.7.2)
17021 This package provides the capability of associating arbitrary
17022 task-specific data with separate tasks.
17023
17024 @item Ada.Task_Identifification (C.7.1)
17025 This package provides capabilities for task identification.
17026
17027 @item Ada.Task_Termination (C.7.3)
17028 This package provides control over task termination.
17029
17030 @item Ada.Text_IO
17031 This package provides basic text input-output capabilities for
17032 character, string and numeric data. The subpackages of this
17033 package are listed next. Note that although these are defined
17034 as subpackages in the RM, they are actually transparently
17035 implemented as child packages in GNAT, meaning that they
17036 are only loaded if needed.
17037
17038 @item Ada.Text_IO.Decimal_IO
17039 Provides input-output facilities for decimal fixed-point types
17040
17041 @item Ada.Text_IO.Enumeration_IO
17042 Provides input-output facilities for enumeration types.
17043
17044 @item Ada.Text_IO.Fixed_IO
17045 Provides input-output facilities for ordinary fixed-point types.
17046
17047 @item Ada.Text_IO.Float_IO
17048 Provides input-output facilities for float types. The following
17049 predefined instantiations of this generic package are available:
17050
17051 @table @code
17052 @item Short_Float
17053 @code{Short_Float_Text_IO}
17054 @item Float
17055 @code{Float_Text_IO}
17056 @item Long_Float
17057 @code{Long_Float_Text_IO}
17058 @end table
17059
17060 @item Ada.Text_IO.Integer_IO
17061 Provides input-output facilities for integer types. The following
17062 predefined instantiations of this generic package are available:
17063
17064 @table @code
17065 @item Short_Short_Integer
17066 @code{Ada.Short_Short_Integer_Text_IO}
17067 @item Short_Integer
17068 @code{Ada.Short_Integer_Text_IO}
17069 @item Integer
17070 @code{Ada.Integer_Text_IO}
17071 @item Long_Integer
17072 @code{Ada.Long_Integer_Text_IO}
17073 @item Long_Long_Integer
17074 @code{Ada.Long_Long_Integer_Text_IO}
17075 @end table
17076
17077 @item Ada.Text_IO.Modular_IO
17078 Provides input-output facilities for modular (unsigned) types.
17079
17080 @item Ada.Text_IO.Bounded_IO (A.10.11)
17081 Provides input-output facilities for bounded strings.
17082
17083 @item Ada.Text_IO.Complex_IO (G.1.3)
17084 This package provides basic text input-output capabilities for complex
17085 data.
17086
17087 @item Ada.Text_IO.Editing (F.3.3)
17088 This package contains routines for edited output, analogous to the use
17089 of pictures in COBOL@. The picture formats used by this package are a
17090 close copy of the facility in COBOL@.
17091
17092 @item Ada.Text_IO.Text_Streams (A.12.2)
17093 This package provides a facility that allows Text_IO files to be treated
17094 as streams, so that the stream attributes can be used for writing
17095 arbitrary data, including binary data, to Text_IO files.
17096
17097 @item Ada.Text_IO.Unbounded_IO (A.10.12)
17098 This package provides input-output facilities for unbounded strings.
17099
17100 @item Ada.Unchecked_Conversion (13.9)
17101 This generic package allows arbitrary conversion from one type to
17102 another of the same size, providing for breaking the type safety in
17103 special circumstances.
17104
17105 If the types have the same Size (more accurately the same Value_Size),
17106 then the effect is simply to transfer the bits from the source to the
17107 target type without any modification. This usage is well defined, and
17108 for simple types whose representation is typically the same across
17109 all implementations, gives a portable method of performing such
17110 conversions.
17111
17112 If the types do not have the same size, then the result is implementation
17113 defined, and thus may be non-portable. The following describes how GNAT
17114 handles such unchecked conversion cases.
17115
17116 If the types are of different sizes, and are both discrete types, then
17117 the effect is of a normal type conversion without any constraint checking.
17118 In particular if the result type has a larger size, the result will be
17119 zero or sign extended. If the result type has a smaller size, the result
17120 will be truncated by ignoring high order bits.
17121
17122 If the types are of different sizes, and are not both discrete types,
17123 then the conversion works as though pointers were created to the source
17124 and target, and the pointer value is converted. The effect is that bits
17125 are copied from successive low order storage units and bits of the source
17126 up to the length of the target type.
17127
17128 A warning is issued if the lengths differ, since the effect in this
17129 case is implementation dependent, and the above behavior may not match
17130 that of some other compiler.
17131
17132 A pointer to one type may be converted to a pointer to another type using
17133 unchecked conversion. The only case in which the effect is undefined is
17134 when one or both pointers are pointers to unconstrained array types. In
17135 this case, the bounds information may get incorrectly transferred, and in
17136 particular, GNAT uses double size pointers for such types, and it is
17137 meaningless to convert between such pointer types. GNAT will issue a
17138 warning if the alignment of the target designated type is more strict
17139 than the alignment of the source designated type (since the result may
17140 be unaligned in this case).
17141
17142 A pointer other than a pointer to an unconstrained array type may be
17143 converted to and from System.Address. Such usage is common in Ada 83
17144 programs, but note that Ada.Address_To_Access_Conversions is the
17145 preferred method of performing such conversions in Ada 95 and Ada 2005.
17146 Neither
17147 unchecked conversion nor Ada.Address_To_Access_Conversions should be
17148 used in conjunction with pointers to unconstrained objects, since
17149 the bounds information cannot be handled correctly in this case.
17150
17151 @item Ada.Unchecked_Deallocation (13.11.2)
17152 This generic package allows explicit freeing of storage previously
17153 allocated by use of an allocator.
17154
17155 @item Ada.Wide_Text_IO (A.11)
17156 This package is similar to @code{Ada.Text_IO}, except that the external
17157 file supports wide character representations, and the internal types are
17158 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17159 and @code{String}. The corresponding set of nested packages and child
17160 packages are defined.
17161
17162 @item Ada.Wide_Wide_Text_IO (A.11)
17163 This package is similar to @code{Ada.Text_IO}, except that the external
17164 file supports wide character representations, and the internal types are
17165 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17166 and @code{String}. The corresponding set of nested packages and child
17167 packages are defined.
17168
17169 @end table
17170
17171 For packages in Interfaces and System, all the RM defined packages are
17172 available in GNAT, see the Ada 2012 RM for full details.
17173
17174 @node The Implementation of Standard I/O
17175 @chapter The Implementation of Standard I/O
17176
17177 @noindent
17178 GNAT implements all the required input-output facilities described in
17179 A.6 through A.14. These sections of the Ada Reference Manual describe the
17180 required behavior of these packages from the Ada point of view, and if
17181 you are writing a portable Ada program that does not need to know the
17182 exact manner in which Ada maps to the outside world when it comes to
17183 reading or writing external files, then you do not need to read this
17184 chapter. As long as your files are all regular files (not pipes or
17185 devices), and as long as you write and read the files only from Ada, the
17186 description in the Ada Reference Manual is sufficient.
17187
17188 However, if you want to do input-output to pipes or other devices, such
17189 as the keyboard or screen, or if the files you are dealing with are
17190 either generated by some other language, or to be read by some other
17191 language, then you need to know more about the details of how the GNAT
17192 implementation of these input-output facilities behaves.
17193
17194 In this chapter we give a detailed description of exactly how GNAT
17195 interfaces to the file system. As always, the sources of the system are
17196 available to you for answering questions at an even more detailed level,
17197 but for most purposes the information in this chapter will suffice.
17198
17199 Another reason that you may need to know more about how input-output is
17200 implemented arises when you have a program written in mixed languages
17201 where, for example, files are shared between the C and Ada sections of
17202 the same program. GNAT provides some additional facilities, in the form
17203 of additional child library packages, that facilitate this sharing, and
17204 these additional facilities are also described in this chapter.
17205
17206 @menu
17207 * Standard I/O Packages::
17208 * FORM Strings::
17209 * Direct_IO::
17210 * Sequential_IO::
17211 * Text_IO::
17212 * Wide_Text_IO::
17213 * Wide_Wide_Text_IO::
17214 * Stream_IO::
17215 * Text Translation::
17216 * Shared Files::
17217 * Filenames encoding::
17218 * Open Modes::
17219 * Operations on C Streams::
17220 * Interfacing to C Streams::
17221 @end menu
17222
17223 @node Standard I/O Packages
17224 @section Standard I/O Packages
17225
17226 @noindent
17227 The Standard I/O packages described in Annex A for
17228
17229 @itemize @bullet
17230 @item
17231 Ada.Text_IO
17232 @item
17233 Ada.Text_IO.Complex_IO
17234 @item
17235 Ada.Text_IO.Text_Streams
17236 @item
17237 Ada.Wide_Text_IO
17238 @item
17239 Ada.Wide_Text_IO.Complex_IO
17240 @item
17241 Ada.Wide_Text_IO.Text_Streams
17242 @item
17243 Ada.Wide_Wide_Text_IO
17244 @item
17245 Ada.Wide_Wide_Text_IO.Complex_IO
17246 @item
17247 Ada.Wide_Wide_Text_IO.Text_Streams
17248 @item
17249 Ada.Stream_IO
17250 @item
17251 Ada.Sequential_IO
17252 @item
17253 Ada.Direct_IO
17254 @end itemize
17255
17256 @noindent
17257 are implemented using the C
17258 library streams facility; where
17259
17260 @itemize @bullet
17261 @item
17262 All files are opened using @code{fopen}.
17263 @item
17264 All input/output operations use @code{fread}/@code{fwrite}.
17265 @end itemize
17266
17267 @noindent
17268 There is no internal buffering of any kind at the Ada library level. The only
17269 buffering is that provided at the system level in the implementation of the
17270 library routines that support streams. This facilitates shared use of these
17271 streams by mixed language programs. Note though that system level buffering is
17272 explicitly enabled at elaboration of the standard I/O packages and that can
17273 have an impact on mixed language programs, in particular those using I/O before
17274 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
17275 the Ada elaboration routine before performing any I/O or when impractical,
17276 flush the common I/O streams and in particular Standard_Output before
17277 elaborating the Ada code.
17278
17279 @node FORM Strings
17280 @section FORM Strings
17281
17282 @noindent
17283 The format of a FORM string in GNAT is:
17284
17285 @smallexample
17286 "keyword=value,keyword=value,@dots{},keyword=value"
17287 @end smallexample
17288
17289 @noindent
17290 where letters may be in upper or lower case, and there are no spaces
17291 between values. The order of the entries is not important. Currently
17292 the following keywords defined.
17293
17294 @smallexample
17295 TEXT_TRANSLATION=[YES|NO]
17296 SHARED=[YES|NO]
17297 WCEM=[n|h|u|s|e|8|b]
17298 ENCODING=[UTF8|8BITS]
17299 @end smallexample
17300
17301 @noindent
17302 The use of these parameters is described later in this section. If an
17303 unrecognized keyword appears in a form string, it is silently ignored
17304 and not considered invalid.
17305
17306 @noindent
17307 For OpenVMS additional FORM string keywords are available for use with
17308 RMS services. The syntax is:
17309
17310 @smallexample
17311 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
17312 @end smallexample
17313
17314 @noindent
17315 The following RMS keywords and values are currently defined:
17316
17317 @smallexample
17318 Context=Force_Stream_Mode|Force_Record_Mode
17319 @end smallexample
17320
17321 @noindent
17322 VMS RMS keys are silently ignored on non-VMS systems. On OpenVMS
17323 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
17324
17325 @node Direct_IO
17326 @section Direct_IO
17327
17328 @noindent
17329 Direct_IO can only be instantiated for definite types. This is a
17330 restriction of the Ada language, which means that the records are fixed
17331 length (the length being determined by @code{@var{type}'Size}, rounded
17332 up to the next storage unit boundary if necessary).
17333
17334 The records of a Direct_IO file are simply written to the file in index
17335 sequence, with the first record starting at offset zero, and subsequent
17336 records following. There is no control information of any kind. For
17337 example, if 32-bit integers are being written, each record takes
17338 4-bytes, so the record at index @var{K} starts at offset
17339 (@var{K}@minus{}1)*4.
17340
17341 There is no limit on the size of Direct_IO files, they are expanded as
17342 necessary to accommodate whatever records are written to the file.
17343
17344 @node Sequential_IO
17345 @section Sequential_IO
17346
17347 @noindent
17348 Sequential_IO may be instantiated with either a definite (constrained)
17349 or indefinite (unconstrained) type.
17350
17351 For the definite type case, the elements written to the file are simply
17352 the memory images of the data values with no control information of any
17353 kind. The resulting file should be read using the same type, no validity
17354 checking is performed on input.
17355
17356 For the indefinite type case, the elements written consist of two
17357 parts. First is the size of the data item, written as the memory image
17358 of a @code{Interfaces.C.size_t} value, followed by the memory image of
17359 the data value. The resulting file can only be read using the same
17360 (unconstrained) type. Normal assignment checks are performed on these
17361 read operations, and if these checks fail, @code{Data_Error} is
17362 raised. In particular, in the array case, the lengths must match, and in
17363 the variant record case, if the variable for a particular read operation
17364 is constrained, the discriminants must match.
17365
17366 Note that it is not possible to use Sequential_IO to write variable
17367 length array items, and then read the data back into different length
17368 arrays. For example, the following will raise @code{Data_Error}:
17369
17370 @smallexample @c ada
17371 package IO is new Sequential_IO (String);
17372 F : IO.File_Type;
17373 S : String (1..4);
17374 @dots{}
17375 IO.Create (F)
17376 IO.Write (F, "hello!")
17377 IO.Reset (F, Mode=>In_File);
17378 IO.Read (F, S);
17379 Put_Line (S);
17380
17381 @end smallexample
17382
17383 @noindent
17384 On some Ada implementations, this will print @code{hell}, but the program is
17385 clearly incorrect, since there is only one element in the file, and that
17386 element is the string @code{hello!}.
17387
17388 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
17389 using Stream_IO, and this is the preferred mechanism. In particular, the
17390 above program fragment rewritten to use Stream_IO will work correctly.
17391
17392 @node Text_IO
17393 @section Text_IO
17394
17395 @noindent
17396 Text_IO files consist of a stream of characters containing the following
17397 special control characters:
17398
17399 @smallexample
17400 LF (line feed, 16#0A#) Line Mark
17401 FF (form feed, 16#0C#) Page Mark
17402 @end smallexample
17403
17404 @noindent
17405 A canonical Text_IO file is defined as one in which the following
17406 conditions are met:
17407
17408 @itemize @bullet
17409 @item
17410 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
17411 of the line.
17412
17413 @item
17414 The character @code{FF} is used only as a page mark, i.e.@: to mark the
17415 end of a page and consequently can appear only immediately following a
17416 @code{LF} (line mark) character.
17417
17418 @item
17419 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
17420 (line mark, page mark). In the former case, the page mark is implicitly
17421 assumed to be present.
17422 @end itemize
17423
17424 @noindent
17425 A file written using Text_IO will be in canonical form provided that no
17426 explicit @code{LF} or @code{FF} characters are written using @code{Put}
17427 or @code{Put_Line}. There will be no @code{FF} character at the end of
17428 the file unless an explicit @code{New_Page} operation was performed
17429 before closing the file.
17430
17431 A canonical Text_IO file that is a regular file (i.e., not a device or a
17432 pipe) can be read using any of the routines in Text_IO@. The
17433 semantics in this case will be exactly as defined in the Ada Reference
17434 Manual, and all the routines in Text_IO are fully implemented.
17435
17436 A text file that does not meet the requirements for a canonical Text_IO
17437 file has one of the following:
17438
17439 @itemize @bullet
17440 @item
17441 The file contains @code{FF} characters not immediately following a
17442 @code{LF} character.
17443
17444 @item
17445 The file contains @code{LF} or @code{FF} characters written by
17446 @code{Put} or @code{Put_Line}, which are not logically considered to be
17447 line marks or page marks.
17448
17449 @item
17450 The file ends in a character other than @code{LF} or @code{FF},
17451 i.e.@: there is no explicit line mark or page mark at the end of the file.
17452 @end itemize
17453
17454 @noindent
17455 Text_IO can be used to read such non-standard text files but subprograms
17456 to do with line or page numbers do not have defined meanings. In
17457 particular, a @code{FF} character that does not follow a @code{LF}
17458 character may or may not be treated as a page mark from the point of
17459 view of page and line numbering. Every @code{LF} character is considered
17460 to end a line, and there is an implied @code{LF} character at the end of
17461 the file.
17462
17463 @menu
17464 * Text_IO Stream Pointer Positioning::
17465 * Text_IO Reading and Writing Non-Regular Files::
17466 * Get_Immediate::
17467 * Treating Text_IO Files as Streams::
17468 * Text_IO Extensions::
17469 * Text_IO Facilities for Unbounded Strings::
17470 @end menu
17471
17472 @node Text_IO Stream Pointer Positioning
17473 @subsection Stream Pointer Positioning
17474
17475 @noindent
17476 @code{Ada.Text_IO} has a definition of current position for a file that
17477 is being read. No internal buffering occurs in Text_IO, and usually the
17478 physical position in the stream used to implement the file corresponds
17479 to this logical position defined by Text_IO@. There are two exceptions:
17480
17481 @itemize @bullet
17482 @item
17483 After a call to @code{End_Of_Page} that returns @code{True}, the stream
17484 is positioned past the @code{LF} (line mark) that precedes the page
17485 mark. Text_IO maintains an internal flag so that subsequent read
17486 operations properly handle the logical position which is unchanged by
17487 the @code{End_Of_Page} call.
17488
17489 @item
17490 After a call to @code{End_Of_File} that returns @code{True}, if the
17491 Text_IO file was positioned before the line mark at the end of file
17492 before the call, then the logical position is unchanged, but the stream
17493 is physically positioned right at the end of file (past the line mark,
17494 and past a possible page mark following the line mark. Again Text_IO
17495 maintains internal flags so that subsequent read operations properly
17496 handle the logical position.
17497 @end itemize
17498
17499 @noindent
17500 These discrepancies have no effect on the observable behavior of
17501 Text_IO, but if a single Ada stream is shared between a C program and
17502 Ada program, or shared (using @samp{shared=yes} in the form string)
17503 between two Ada files, then the difference may be observable in some
17504 situations.
17505
17506 @node Text_IO Reading and Writing Non-Regular Files
17507 @subsection Reading and Writing Non-Regular Files
17508
17509 @noindent
17510 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
17511 can be used for reading and writing. Writing is not affected and the
17512 sequence of characters output is identical to the normal file case, but
17513 for reading, the behavior of Text_IO is modified to avoid undesirable
17514 look-ahead as follows:
17515
17516 An input file that is not a regular file is considered to have no page
17517 marks. Any @code{Ascii.FF} characters (the character normally used for a
17518 page mark) appearing in the file are considered to be data
17519 characters. In particular:
17520
17521 @itemize @bullet
17522 @item
17523 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
17524 following a line mark. If a page mark appears, it will be treated as a
17525 data character.
17526
17527 @item
17528 This avoids the need to wait for an extra character to be typed or
17529 entered from the pipe to complete one of these operations.
17530
17531 @item
17532 @code{End_Of_Page} always returns @code{False}
17533
17534 @item
17535 @code{End_Of_File} will return @code{False} if there is a page mark at
17536 the end of the file.
17537 @end itemize
17538
17539 @noindent
17540 Output to non-regular files is the same as for regular files. Page marks
17541 may be written to non-regular files using @code{New_Page}, but as noted
17542 above they will not be treated as page marks on input if the output is
17543 piped to another Ada program.
17544
17545 Another important discrepancy when reading non-regular files is that the end
17546 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
17547 pressing the @key{EOT} key,
17548 then end of file
17549 is signaled once (i.e.@: the test @code{End_Of_File}
17550 will yield @code{True}, or a read will
17551 raise @code{End_Error}), but then reading can resume
17552 to read data past that end of
17553 file indication, until another end of file indication is entered.
17554
17555 @node Get_Immediate
17556 @subsection Get_Immediate
17557 @cindex Get_Immediate
17558
17559 @noindent
17560 Get_Immediate returns the next character (including control characters)
17561 from the input file. In particular, Get_Immediate will return LF or FF
17562 characters used as line marks or page marks. Such operations leave the
17563 file positioned past the control character, and it is thus not treated
17564 as having its normal function. This means that page, line and column
17565 counts after this kind of Get_Immediate call are set as though the mark
17566 did not occur. In the case where a Get_Immediate leaves the file
17567 positioned between the line mark and page mark (which is not normally
17568 possible), it is undefined whether the FF character will be treated as a
17569 page mark.
17570
17571 @node Treating Text_IO Files as Streams
17572 @subsection Treating Text_IO Files as Streams
17573 @cindex Stream files
17574
17575 @noindent
17576 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
17577 as a stream. Data written to a Text_IO file in this stream mode is
17578 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
17579 16#0C# (@code{FF}), the resulting file may have non-standard
17580 format. Similarly if read operations are used to read from a Text_IO
17581 file treated as a stream, then @code{LF} and @code{FF} characters may be
17582 skipped and the effect is similar to that described above for
17583 @code{Get_Immediate}.
17584
17585 @node Text_IO Extensions
17586 @subsection Text_IO Extensions
17587 @cindex Text_IO extensions
17588
17589 @noindent
17590 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
17591 to the standard @code{Text_IO} package:
17592
17593 @itemize @bullet
17594 @item function File_Exists (Name : String) return Boolean;
17595 Determines if a file of the given name exists.
17596
17597 @item function Get_Line return String;
17598 Reads a string from the standard input file. The value returned is exactly
17599 the length of the line that was read.
17600
17601 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
17602 Similar, except that the parameter File specifies the file from which
17603 the string is to be read.
17604
17605 @end itemize
17606
17607 @node Text_IO Facilities for Unbounded Strings
17608 @subsection Text_IO Facilities for Unbounded Strings
17609 @cindex Text_IO for unbounded strings
17610 @cindex Unbounded_String, Text_IO operations
17611
17612 @noindent
17613 The package @code{Ada.Strings.Unbounded.Text_IO}
17614 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
17615 subprograms useful for Text_IO operations on unbounded strings:
17616
17617 @itemize @bullet
17618
17619 @item function Get_Line (File : File_Type) return Unbounded_String;
17620 Reads a line from the specified file
17621 and returns the result as an unbounded string.
17622
17623 @item procedure Put (File : File_Type; U : Unbounded_String);
17624 Writes the value of the given unbounded string to the specified file
17625 Similar to the effect of
17626 @code{Put (To_String (U))} except that an extra copy is avoided.
17627
17628 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
17629 Writes the value of the given unbounded string to the specified file,
17630 followed by a @code{New_Line}.
17631 Similar to the effect of @code{Put_Line (To_String (U))} except
17632 that an extra copy is avoided.
17633 @end itemize
17634
17635 @noindent
17636 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
17637 and is optional. If the parameter is omitted, then the standard input or
17638 output file is referenced as appropriate.
17639
17640 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
17641 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
17642 @code{Wide_Text_IO} functionality for unbounded wide strings.
17643
17644 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
17645 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
17646 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
17647
17648 @node Wide_Text_IO
17649 @section Wide_Text_IO
17650
17651 @noindent
17652 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
17653 both input and output files may contain special sequences that represent
17654 wide character values. The encoding scheme for a given file may be
17655 specified using a FORM parameter:
17656
17657 @smallexample
17658 WCEM=@var{x}
17659 @end smallexample
17660
17661 @noindent
17662 as part of the FORM string (WCEM = wide character encoding method),
17663 where @var{x} is one of the following characters
17664
17665 @table @samp
17666 @item h
17667 Hex ESC encoding
17668 @item u
17669 Upper half encoding
17670 @item s
17671 Shift-JIS encoding
17672 @item e
17673 EUC Encoding
17674 @item 8
17675 UTF-8 encoding
17676 @item b
17677 Brackets encoding
17678 @end table
17679
17680 @noindent
17681 The encoding methods match those that
17682 can be used in a source
17683 program, but there is no requirement that the encoding method used for
17684 the source program be the same as the encoding method used for files,
17685 and different files may use different encoding methods.
17686
17687 The default encoding method for the standard files, and for opened files
17688 for which no WCEM parameter is given in the FORM string matches the
17689 wide character encoding specified for the main program (the default
17690 being brackets encoding if no coding method was specified with -gnatW).
17691
17692 @table @asis
17693 @item Hex Coding
17694 In this encoding, a wide character is represented by a five character
17695 sequence:
17696
17697 @smallexample
17698 ESC a b c d
17699 @end smallexample
17700
17701 @noindent
17702 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
17703 characters (using upper case letters) of the wide character code. For
17704 example, ESC A345 is used to represent the wide character with code
17705 16#A345#. This scheme is compatible with use of the full
17706 @code{Wide_Character} set.
17707
17708 @item Upper Half Coding
17709 The wide character with encoding 16#abcd#, where the upper bit is on
17710 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
17711 16#cd#. The second byte may never be a format control character, but is
17712 not required to be in the upper half. This method can be also used for
17713 shift-JIS or EUC where the internal coding matches the external coding.
17714
17715 @item Shift JIS Coding
17716 A wide character is represented by a two character sequence 16#ab# and
17717 16#cd#, with the restrictions described for upper half encoding as
17718 described above. The internal character code is the corresponding JIS
17719 character according to the standard algorithm for Shift-JIS
17720 conversion. Only characters defined in the JIS code set table can be
17721 used with this encoding method.
17722
17723 @item EUC Coding
17724 A wide character is represented by a two character sequence 16#ab# and
17725 16#cd#, with both characters being in the upper half. The internal
17726 character code is the corresponding JIS character according to the EUC
17727 encoding algorithm. Only characters defined in the JIS code set table
17728 can be used with this encoding method.
17729
17730 @item UTF-8 Coding
17731 A wide character is represented using
17732 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
17733 10646-1/Am.2. Depending on the character value, the representation
17734 is a one, two, or three byte sequence:
17735
17736 @smallexample
17737 16#0000#-16#007f#: 2#0xxxxxxx#
17738 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
17739 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
17740 @end smallexample
17741
17742 @noindent
17743 where the @var{xxx} bits correspond to the left-padded bits of the
17744 16-bit character value. Note that all lower half ASCII characters
17745 are represented as ASCII bytes and all upper half characters and
17746 other wide characters are represented as sequences of upper-half
17747 (The full UTF-8 scheme allows for encoding 31-bit characters as
17748 6-byte sequences, but in this implementation, all UTF-8 sequences
17749 of four or more bytes length will raise a Constraint_Error, as
17750 will all invalid UTF-8 sequences.)
17751
17752 @item Brackets Coding
17753 In this encoding, a wide character is represented by the following eight
17754 character sequence:
17755
17756 @smallexample
17757 [ " a b c d " ]
17758 @end smallexample
17759
17760 @noindent
17761 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
17762 characters (using uppercase letters) of the wide character code. For
17763 example, @code{["A345"]} is used to represent the wide character with code
17764 @code{16#A345#}.
17765 This scheme is compatible with use of the full Wide_Character set.
17766 On input, brackets coding can also be used for upper half characters,
17767 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
17768 is only used for wide characters with a code greater than @code{16#FF#}.
17769
17770 Note that brackets coding is not normally used in the context of
17771 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
17772 a portable way of encoding source files. In the context of Wide_Text_IO
17773 or Wide_Wide_Text_IO, it can only be used if the file does not contain
17774 any instance of the left bracket character other than to encode wide
17775 character values using the brackets encoding method. In practice it is
17776 expected that some standard wide character encoding method such
17777 as UTF-8 will be used for text input output.
17778
17779 If brackets notation is used, then any occurrence of a left bracket
17780 in the input file which is not the start of a valid wide character
17781 sequence will cause Constraint_Error to be raised. It is possible to
17782 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
17783 input will interpret this as a left bracket.
17784
17785 However, when a left bracket is output, it will be output as a left bracket
17786 and not as ["5B"]. We make this decision because for normal use of
17787 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
17788 brackets. For example, if we write:
17789
17790 @smallexample
17791 Put_Line ("Start of output [first run]");
17792 @end smallexample
17793
17794 @noindent
17795 we really do not want to have the left bracket in this message clobbered so
17796 that the output reads:
17797
17798 @smallexample
17799 Start of output ["5B"]first run]
17800 @end smallexample
17801
17802 @noindent
17803 In practice brackets encoding is reasonably useful for normal Put_Line use
17804 since we won't get confused between left brackets and wide character
17805 sequences in the output. But for input, or when files are written out
17806 and read back in, it really makes better sense to use one of the standard
17807 encoding methods such as UTF-8.
17808
17809 @end table
17810
17811 @noindent
17812 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
17813 not all wide character
17814 values can be represented. An attempt to output a character that cannot
17815 be represented using the encoding scheme for the file causes
17816 Constraint_Error to be raised. An invalid wide character sequence on
17817 input also causes Constraint_Error to be raised.
17818
17819 @menu
17820 * Wide_Text_IO Stream Pointer Positioning::
17821 * Wide_Text_IO Reading and Writing Non-Regular Files::
17822 @end menu
17823
17824 @node Wide_Text_IO Stream Pointer Positioning
17825 @subsection Stream Pointer Positioning
17826
17827 @noindent
17828 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
17829 of stream pointer positioning (@pxref{Text_IO}). There is one additional
17830 case:
17831
17832 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
17833 normal lower ASCII set (i.e.@: a character in the range:
17834
17835 @smallexample @c ada
17836 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
17837 @end smallexample
17838
17839 @noindent
17840 then although the logical position of the file pointer is unchanged by
17841 the @code{Look_Ahead} call, the stream is physically positioned past the
17842 wide character sequence. Again this is to avoid the need for buffering
17843 or backup, and all @code{Wide_Text_IO} routines check the internal
17844 indication that this situation has occurred so that this is not visible
17845 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
17846 can be observed if the wide text file shares a stream with another file.
17847
17848 @node Wide_Text_IO Reading and Writing Non-Regular Files
17849 @subsection Reading and Writing Non-Regular Files
17850
17851 @noindent
17852 As in the case of Text_IO, when a non-regular file is read, it is
17853 assumed that the file contains no page marks (any form characters are
17854 treated as data characters), and @code{End_Of_Page} always returns
17855 @code{False}. Similarly, the end of file indication is not sticky, so
17856 it is possible to read beyond an end of file.
17857
17858 @node Wide_Wide_Text_IO
17859 @section Wide_Wide_Text_IO
17860
17861 @noindent
17862 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
17863 both input and output files may contain special sequences that represent
17864 wide wide character values. The encoding scheme for a given file may be
17865 specified using a FORM parameter:
17866
17867 @smallexample
17868 WCEM=@var{x}
17869 @end smallexample
17870
17871 @noindent
17872 as part of the FORM string (WCEM = wide character encoding method),
17873 where @var{x} is one of the following characters
17874
17875 @table @samp
17876 @item h
17877 Hex ESC encoding
17878 @item u
17879 Upper half encoding
17880 @item s
17881 Shift-JIS encoding
17882 @item e
17883 EUC Encoding
17884 @item 8
17885 UTF-8 encoding
17886 @item b
17887 Brackets encoding
17888 @end table
17889
17890 @noindent
17891 The encoding methods match those that
17892 can be used in a source
17893 program, but there is no requirement that the encoding method used for
17894 the source program be the same as the encoding method used for files,
17895 and different files may use different encoding methods.
17896
17897 The default encoding method for the standard files, and for opened files
17898 for which no WCEM parameter is given in the FORM string matches the
17899 wide character encoding specified for the main program (the default
17900 being brackets encoding if no coding method was specified with -gnatW).
17901
17902 @table @asis
17903
17904 @item UTF-8 Coding
17905 A wide character is represented using
17906 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
17907 10646-1/Am.2. Depending on the character value, the representation
17908 is a one, two, three, or four byte sequence:
17909
17910 @smallexample
17911 16#000000#-16#00007f#: 2#0xxxxxxx#
17912 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
17913 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
17914 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
17915 @end smallexample
17916
17917 @noindent
17918 where the @var{xxx} bits correspond to the left-padded bits of the
17919 21-bit character value. Note that all lower half ASCII characters
17920 are represented as ASCII bytes and all upper half characters and
17921 other wide characters are represented as sequences of upper-half
17922 characters.
17923
17924 @item Brackets Coding
17925 In this encoding, a wide wide character is represented by the following eight
17926 character sequence if is in wide character range
17927
17928 @smallexample
17929 [ " a b c d " ]
17930 @end smallexample
17931
17932 and by the following ten character sequence if not
17933
17934 @smallexample
17935 [ " a b c d e f " ]
17936 @end smallexample
17937
17938 @noindent
17939 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
17940 are the four or six hexadecimal
17941 characters (using uppercase letters) of the wide wide character code. For
17942 example, @code{["01A345"]} is used to represent the wide wide character
17943 with code @code{16#01A345#}.
17944
17945 This scheme is compatible with use of the full Wide_Wide_Character set.
17946 On input, brackets coding can also be used for upper half characters,
17947 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
17948 is only used for wide characters with a code greater than @code{16#FF#}.
17949
17950 @end table
17951
17952 @noindent
17953 If is also possible to use the other Wide_Character encoding methods,
17954 such as Shift-JIS, but the other schemes cannot support the full range
17955 of wide wide characters.
17956 An attempt to output a character that cannot
17957 be represented using the encoding scheme for the file causes
17958 Constraint_Error to be raised. An invalid wide character sequence on
17959 input also causes Constraint_Error to be raised.
17960
17961 @menu
17962 * Wide_Wide_Text_IO Stream Pointer Positioning::
17963 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
17964 @end menu
17965
17966 @node Wide_Wide_Text_IO Stream Pointer Positioning
17967 @subsection Stream Pointer Positioning
17968
17969 @noindent
17970 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
17971 of stream pointer positioning (@pxref{Text_IO}). There is one additional
17972 case:
17973
17974 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
17975 normal lower ASCII set (i.e.@: a character in the range:
17976
17977 @smallexample @c ada
17978 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
17979 @end smallexample
17980
17981 @noindent
17982 then although the logical position of the file pointer is unchanged by
17983 the @code{Look_Ahead} call, the stream is physically positioned past the
17984 wide character sequence. Again this is to avoid the need for buffering
17985 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
17986 indication that this situation has occurred so that this is not visible
17987 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
17988 can be observed if the wide text file shares a stream with another file.
17989
17990 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
17991 @subsection Reading and Writing Non-Regular Files
17992
17993 @noindent
17994 As in the case of Text_IO, when a non-regular file is read, it is
17995 assumed that the file contains no page marks (any form characters are
17996 treated as data characters), and @code{End_Of_Page} always returns
17997 @code{False}. Similarly, the end of file indication is not sticky, so
17998 it is possible to read beyond an end of file.
17999
18000 @node Stream_IO
18001 @section Stream_IO
18002
18003 @noindent
18004 A stream file is a sequence of bytes, where individual elements are
18005 written to the file as described in the Ada Reference Manual. The type
18006 @code{Stream_Element} is simply a byte. There are two ways to read or
18007 write a stream file.
18008
18009 @itemize @bullet
18010 @item
18011 The operations @code{Read} and @code{Write} directly read or write a
18012 sequence of stream elements with no control information.
18013
18014 @item
18015 The stream attributes applied to a stream file transfer data in the
18016 manner described for stream attributes.
18017 @end itemize
18018
18019 @node Text Translation
18020 @section Text Translation
18021
18022 @noindent
18023 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
18024 passed to Text_IO.Create and Text_IO.Open:
18025 @samp{Text_Translation=@var{Yes}} is the default, which means to
18026 translate LF to/from CR/LF on Windows systems.
18027 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
18028 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
18029 may be used to create Unix-style files on
18030 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
18031 systems.
18032
18033 @node Shared Files
18034 @section Shared Files
18035
18036 @noindent
18037 Section A.14 of the Ada Reference Manual allows implementations to
18038 provide a wide variety of behavior if an attempt is made to access the
18039 same external file with two or more internal files.
18040
18041 To provide a full range of functionality, while at the same time
18042 minimizing the problems of portability caused by this implementation
18043 dependence, GNAT handles file sharing as follows:
18044
18045 @itemize @bullet
18046 @item
18047 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
18048 to open two or more files with the same full name is considered an error
18049 and is not supported. The exception @code{Use_Error} will be
18050 raised. Note that a file that is not explicitly closed by the program
18051 remains open until the program terminates.
18052
18053 @item
18054 If the form parameter @samp{shared=no} appears in the form string, the
18055 file can be opened or created with its own separate stream identifier,
18056 regardless of whether other files sharing the same external file are
18057 opened. The exact effect depends on how the C stream routines handle
18058 multiple accesses to the same external files using separate streams.
18059
18060 @item
18061 If the form parameter @samp{shared=yes} appears in the form string for
18062 each of two or more files opened using the same full name, the same
18063 stream is shared between these files, and the semantics are as described
18064 in Ada Reference Manual, Section A.14.
18065 @end itemize
18066
18067 @noindent
18068 When a program that opens multiple files with the same name is ported
18069 from another Ada compiler to GNAT, the effect will be that
18070 @code{Use_Error} is raised.
18071
18072 The documentation of the original compiler and the documentation of the
18073 program should then be examined to determine if file sharing was
18074 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
18075 and @code{Create} calls as required.
18076
18077 When a program is ported from GNAT to some other Ada compiler, no
18078 special attention is required unless the @samp{shared=@var{xxx}} form
18079 parameter is used in the program. In this case, you must examine the
18080 documentation of the new compiler to see if it supports the required
18081 file sharing semantics, and form strings modified appropriately. Of
18082 course it may be the case that the program cannot be ported if the
18083 target compiler does not support the required functionality. The best
18084 approach in writing portable code is to avoid file sharing (and hence
18085 the use of the @samp{shared=@var{xxx}} parameter in the form string)
18086 completely.
18087
18088 One common use of file sharing in Ada 83 is the use of instantiations of
18089 Sequential_IO on the same file with different types, to achieve
18090 heterogeneous input-output. Although this approach will work in GNAT if
18091 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
18092 for this purpose (using the stream attributes)
18093
18094 @node Filenames encoding
18095 @section Filenames encoding
18096
18097 @noindent
18098 An encoding form parameter can be used to specify the filename
18099 encoding @samp{encoding=@var{xxx}}.
18100
18101 @itemize @bullet
18102 @item
18103 If the form parameter @samp{encoding=utf8} appears in the form string, the
18104 filename must be encoded in UTF-8.
18105
18106 @item
18107 If the form parameter @samp{encoding=8bits} appears in the form
18108 string, the filename must be a standard 8bits string.
18109 @end itemize
18110
18111 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
18112 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
18113 variable. And if not set @samp{utf8} is assumed.
18114
18115 @table @samp
18116 @item CP_ACP
18117 The current system Windows ANSI code page.
18118 @item CP_UTF8
18119 UTF-8 encoding
18120 @end table
18121
18122 This encoding form parameter is only supported on the Windows
18123 platform. On the other Operating Systems the run-time is supporting
18124 UTF-8 natively.
18125
18126 @node Open Modes
18127 @section Open Modes
18128
18129 @noindent
18130 @code{Open} and @code{Create} calls result in a call to @code{fopen}
18131 using the mode shown in the following table:
18132
18133 @sp 2
18134 @center @code{Open} and @code{Create} Call Modes
18135 @smallexample
18136 @b{OPEN } @b{CREATE}
18137 Append_File "r+" "w+"
18138 In_File "r" "w+"
18139 Out_File (Direct_IO) "r+" "w"
18140 Out_File (all other cases) "w" "w"
18141 Inout_File "r+" "w+"
18142 @end smallexample
18143
18144 @noindent
18145 If text file translation is required, then either @samp{b} or @samp{t}
18146 is added to the mode, depending on the setting of Text. Text file
18147 translation refers to the mapping of CR/LF sequences in an external file
18148 to LF characters internally. This mapping only occurs in DOS and
18149 DOS-like systems, and is not relevant to other systems.
18150
18151 A special case occurs with Stream_IO@. As shown in the above table, the
18152 file is initially opened in @samp{r} or @samp{w} mode for the
18153 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
18154 subsequently requires switching from reading to writing or vice-versa,
18155 then the file is reopened in @samp{r+} mode to permit the required operation.
18156
18157 @node Operations on C Streams
18158 @section Operations on C Streams
18159 The package @code{Interfaces.C_Streams} provides an Ada program with direct
18160 access to the C library functions for operations on C streams:
18161
18162 @smallexample @c adanocomment
18163 package Interfaces.C_Streams is
18164 -- Note: the reason we do not use the types that are in
18165 -- Interfaces.C is that we want to avoid dragging in the
18166 -- code in this unit if possible.
18167 subtype chars is System.Address;
18168 -- Pointer to null-terminated array of characters
18169 subtype FILEs is System.Address;
18170 -- Corresponds to the C type FILE*
18171 subtype voids is System.Address;
18172 -- Corresponds to the C type void*
18173 subtype int is Integer;
18174 subtype long is Long_Integer;
18175 -- Note: the above types are subtypes deliberately, and it
18176 -- is part of this spec that the above correspondences are
18177 -- guaranteed. This means that it is legitimate to, for
18178 -- example, use Integer instead of int. We provide these
18179 -- synonyms for clarity, but in some cases it may be
18180 -- convenient to use the underlying types (for example to
18181 -- avoid an unnecessary dependency of a spec on the spec
18182 -- of this unit).
18183 type size_t is mod 2 ** Standard'Address_Size;
18184 NULL_Stream : constant FILEs;
18185 -- Value returned (NULL in C) to indicate an
18186 -- fdopen/fopen/tmpfile error
18187 ----------------------------------
18188 -- Constants Defined in stdio.h --
18189 ----------------------------------
18190 EOF : constant int;
18191 -- Used by a number of routines to indicate error or
18192 -- end of file
18193 IOFBF : constant int;
18194 IOLBF : constant int;
18195 IONBF : constant int;
18196 -- Used to indicate buffering mode for setvbuf call
18197 SEEK_CUR : constant int;
18198 SEEK_END : constant int;
18199 SEEK_SET : constant int;
18200 -- Used to indicate origin for fseek call
18201 function stdin return FILEs;
18202 function stdout return FILEs;
18203 function stderr return FILEs;
18204 -- Streams associated with standard files
18205 --------------------------
18206 -- Standard C functions --
18207 --------------------------
18208 -- The functions selected below are ones that are
18209 -- available in UNIX (but not necessarily in ANSI C).
18210 -- These are very thin interfaces
18211 -- which copy exactly the C headers. For more
18212 -- documentation on these functions, see the Microsoft C
18213 -- "Run-Time Library Reference" (Microsoft Press, 1990,
18214 -- ISBN 1-55615-225-6), which includes useful information
18215 -- on system compatibility.
18216 procedure clearerr (stream : FILEs);
18217 function fclose (stream : FILEs) return int;
18218 function fdopen (handle : int; mode : chars) return FILEs;
18219 function feof (stream : FILEs) return int;
18220 function ferror (stream : FILEs) return int;
18221 function fflush (stream : FILEs) return int;
18222 function fgetc (stream : FILEs) return int;
18223 function fgets (strng : chars; n : int; stream : FILEs)
18224 return chars;
18225 function fileno (stream : FILEs) return int;
18226 function fopen (filename : chars; Mode : chars)
18227 return FILEs;
18228 -- Note: to maintain target independence, use
18229 -- text_translation_required, a boolean variable defined in
18230 -- a-sysdep.c to deal with the target dependent text
18231 -- translation requirement. If this variable is set,
18232 -- then b/t should be appended to the standard mode
18233 -- argument to set the text translation mode off or on
18234 -- as required.
18235 function fputc (C : int; stream : FILEs) return int;
18236 function fputs (Strng : chars; Stream : FILEs) return int;
18237 function fread
18238 (buffer : voids;
18239 size : size_t;
18240 count : size_t;
18241 stream : FILEs)
18242 return size_t;
18243 function freopen
18244 (filename : chars;
18245 mode : chars;
18246 stream : FILEs)
18247 return FILEs;
18248 function fseek
18249 (stream : FILEs;
18250 offset : long;
18251 origin : int)
18252 return int;
18253 function ftell (stream : FILEs) return long;
18254 function fwrite
18255 (buffer : voids;
18256 size : size_t;
18257 count : size_t;
18258 stream : FILEs)
18259 return size_t;
18260 function isatty (handle : int) return int;
18261 procedure mktemp (template : chars);
18262 -- The return value (which is just a pointer to template)
18263 -- is discarded
18264 procedure rewind (stream : FILEs);
18265 function rmtmp return int;
18266 function setvbuf
18267 (stream : FILEs;
18268 buffer : chars;
18269 mode : int;
18270 size : size_t)
18271 return int;
18272
18273 function tmpfile return FILEs;
18274 function ungetc (c : int; stream : FILEs) return int;
18275 function unlink (filename : chars) return int;
18276 ---------------------
18277 -- Extra functions --
18278 ---------------------
18279 -- These functions supply slightly thicker bindings than
18280 -- those above. They are derived from functions in the
18281 -- C Run-Time Library, but may do a bit more work than
18282 -- just directly calling one of the Library functions.
18283 function is_regular_file (handle : int) return int;
18284 -- Tests if given handle is for a regular file (result 1)
18285 -- or for a non-regular file (pipe or device, result 0).
18286 ---------------------------------
18287 -- Control of Text/Binary Mode --
18288 ---------------------------------
18289 -- If text_translation_required is true, then the following
18290 -- functions may be used to dynamically switch a file from
18291 -- binary to text mode or vice versa. These functions have
18292 -- no effect if text_translation_required is false (i.e.@: in
18293 -- normal UNIX mode). Use fileno to get a stream handle.
18294 procedure set_binary_mode (handle : int);
18295 procedure set_text_mode (handle : int);
18296 ----------------------------
18297 -- Full Path Name support --
18298 ----------------------------
18299 procedure full_name (nam : chars; buffer : chars);
18300 -- Given a NUL terminated string representing a file
18301 -- name, returns in buffer a NUL terminated string
18302 -- representing the full path name for the file name.
18303 -- On systems where it is relevant the drive is also
18304 -- part of the full path name. It is the responsibility
18305 -- of the caller to pass an actual parameter for buffer
18306 -- that is big enough for any full path name. Use
18307 -- max_path_len given below as the size of buffer.
18308 max_path_len : integer;
18309 -- Maximum length of an allowable full path name on the
18310 -- system, including a terminating NUL character.
18311 end Interfaces.C_Streams;
18312 @end smallexample
18313
18314 @node Interfacing to C Streams
18315 @section Interfacing to C Streams
18316
18317 @noindent
18318 The packages in this section permit interfacing Ada files to C Stream
18319 operations.
18320
18321 @smallexample @c ada
18322 with Interfaces.C_Streams;
18323 package Ada.Sequential_IO.C_Streams is
18324 function C_Stream (F : File_Type)
18325 return Interfaces.C_Streams.FILEs;
18326 procedure Open
18327 (File : in out File_Type;
18328 Mode : in File_Mode;
18329 C_Stream : in Interfaces.C_Streams.FILEs;
18330 Form : in String := "");
18331 end Ada.Sequential_IO.C_Streams;
18332
18333 with Interfaces.C_Streams;
18334 package Ada.Direct_IO.C_Streams is
18335 function C_Stream (F : File_Type)
18336 return Interfaces.C_Streams.FILEs;
18337 procedure Open
18338 (File : in out File_Type;
18339 Mode : in File_Mode;
18340 C_Stream : in Interfaces.C_Streams.FILEs;
18341 Form : in String := "");
18342 end Ada.Direct_IO.C_Streams;
18343
18344 with Interfaces.C_Streams;
18345 package Ada.Text_IO.C_Streams is
18346 function C_Stream (F : File_Type)
18347 return Interfaces.C_Streams.FILEs;
18348 procedure Open
18349 (File : in out File_Type;
18350 Mode : in File_Mode;
18351 C_Stream : in Interfaces.C_Streams.FILEs;
18352 Form : in String := "");
18353 end Ada.Text_IO.C_Streams;
18354
18355 with Interfaces.C_Streams;
18356 package Ada.Wide_Text_IO.C_Streams is
18357 function C_Stream (F : File_Type)
18358 return Interfaces.C_Streams.FILEs;
18359 procedure Open
18360 (File : in out File_Type;
18361 Mode : in File_Mode;
18362 C_Stream : in Interfaces.C_Streams.FILEs;
18363 Form : in String := "");
18364 end Ada.Wide_Text_IO.C_Streams;
18365
18366 with Interfaces.C_Streams;
18367 package Ada.Wide_Wide_Text_IO.C_Streams is
18368 function C_Stream (F : File_Type)
18369 return Interfaces.C_Streams.FILEs;
18370 procedure Open
18371 (File : in out File_Type;
18372 Mode : in File_Mode;
18373 C_Stream : in Interfaces.C_Streams.FILEs;
18374 Form : in String := "");
18375 end Ada.Wide_Wide_Text_IO.C_Streams;
18376
18377 with Interfaces.C_Streams;
18378 package Ada.Stream_IO.C_Streams is
18379 function C_Stream (F : File_Type)
18380 return Interfaces.C_Streams.FILEs;
18381 procedure Open
18382 (File : in out File_Type;
18383 Mode : in File_Mode;
18384 C_Stream : in Interfaces.C_Streams.FILEs;
18385 Form : in String := "");
18386 end Ada.Stream_IO.C_Streams;
18387 @end smallexample
18388
18389 @noindent
18390 In each of these six packages, the @code{C_Stream} function obtains the
18391 @code{FILE} pointer from a currently opened Ada file. It is then
18392 possible to use the @code{Interfaces.C_Streams} package to operate on
18393 this stream, or the stream can be passed to a C program which can
18394 operate on it directly. Of course the program is responsible for
18395 ensuring that only appropriate sequences of operations are executed.
18396
18397 One particular use of relevance to an Ada program is that the
18398 @code{setvbuf} function can be used to control the buffering of the
18399 stream used by an Ada file. In the absence of such a call the standard
18400 default buffering is used.
18401
18402 The @code{Open} procedures in these packages open a file giving an
18403 existing C Stream instead of a file name. Typically this stream is
18404 imported from a C program, allowing an Ada file to operate on an
18405 existing C file.
18406
18407 @node The GNAT Library
18408 @chapter The GNAT Library
18409
18410 @noindent
18411 The GNAT library contains a number of general and special purpose packages.
18412 It represents functionality that the GNAT developers have found useful, and
18413 which is made available to GNAT users. The packages described here are fully
18414 supported, and upwards compatibility will be maintained in future releases,
18415 so you can use these facilities with the confidence that the same functionality
18416 will be available in future releases.
18417
18418 The chapter here simply gives a brief summary of the facilities available.
18419 The full documentation is found in the spec file for the package. The full
18420 sources of these library packages, including both spec and body, are provided
18421 with all GNAT releases. For example, to find out the full specifications of
18422 the SPITBOL pattern matching capability, including a full tutorial and
18423 extensive examples, look in the @file{g-spipat.ads} file in the library.
18424
18425 For each entry here, the package name (as it would appear in a @code{with}
18426 clause) is given, followed by the name of the corresponding spec file in
18427 parentheses. The packages are children in four hierarchies, @code{Ada},
18428 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
18429 GNAT-specific hierarchy.
18430
18431 Note that an application program should only use packages in one of these
18432 four hierarchies if the package is defined in the Ada Reference Manual,
18433 or is listed in this section of the GNAT Programmers Reference Manual.
18434 All other units should be considered internal implementation units and
18435 should not be directly @code{with}'ed by application code. The use of
18436 a @code{with} statement that references one of these internal implementation
18437 units makes an application potentially dependent on changes in versions
18438 of GNAT, and will generate a warning message.
18439
18440 @menu
18441 * Ada.Characters.Latin_9 (a-chlat9.ads)::
18442 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
18443 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
18444 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
18445 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
18446 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
18447 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
18448 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
18449 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
18450 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
18451 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
18452 * Ada.Command_Line.Environment (a-colien.ads)::
18453 * Ada.Command_Line.Remove (a-colire.ads)::
18454 * Ada.Command_Line.Response_File (a-clrefi.ads)::
18455 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
18456 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
18457 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
18458 * Ada.Exceptions.Traceback (a-exctra.ads)::
18459 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
18460 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
18461 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
18462 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
18463 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
18464 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
18465 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
18466 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
18467 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
18468 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
18469 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
18470 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
18471 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
18472 * GNAT.Altivec (g-altive.ads)::
18473 * GNAT.Altivec.Conversions (g-altcon.ads)::
18474 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
18475 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
18476 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
18477 * GNAT.Array_Split (g-arrspl.ads)::
18478 * GNAT.AWK (g-awk.ads)::
18479 * GNAT.Bounded_Buffers (g-boubuf.ads)::
18480 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
18481 * GNAT.Bubble_Sort (g-bubsor.ads)::
18482 * GNAT.Bubble_Sort_A (g-busora.ads)::
18483 * GNAT.Bubble_Sort_G (g-busorg.ads)::
18484 * GNAT.Byte_Order_Mark (g-byorma.ads)::
18485 * GNAT.Byte_Swapping (g-bytswa.ads)::
18486 * GNAT.Calendar (g-calend.ads)::
18487 * GNAT.Calendar.Time_IO (g-catiio.ads)::
18488 * GNAT.Case_Util (g-casuti.ads)::
18489 * GNAT.CGI (g-cgi.ads)::
18490 * GNAT.CGI.Cookie (g-cgicoo.ads)::
18491 * GNAT.CGI.Debug (g-cgideb.ads)::
18492 * GNAT.Command_Line (g-comlin.ads)::
18493 * GNAT.Compiler_Version (g-comver.ads)::
18494 * GNAT.Ctrl_C (g-ctrl_c.ads)::
18495 * GNAT.CRC32 (g-crc32.ads)::
18496 * GNAT.Current_Exception (g-curexc.ads)::
18497 * GNAT.Debug_Pools (g-debpoo.ads)::
18498 * GNAT.Debug_Utilities (g-debuti.ads)::
18499 * GNAT.Decode_String (g-decstr.ads)::
18500 * GNAT.Decode_UTF8_String (g-deutst.ads)::
18501 * GNAT.Directory_Operations (g-dirope.ads)::
18502 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
18503 * GNAT.Dynamic_HTables (g-dynhta.ads)::
18504 * GNAT.Dynamic_Tables (g-dyntab.ads)::
18505 * GNAT.Encode_String (g-encstr.ads)::
18506 * GNAT.Encode_UTF8_String (g-enutst.ads)::
18507 * GNAT.Exception_Actions (g-excact.ads)::
18508 * GNAT.Exception_Traces (g-exctra.ads)::
18509 * GNAT.Exceptions (g-except.ads)::
18510 * GNAT.Expect (g-expect.ads)::
18511 * GNAT.Expect.TTY (g-exptty.ads)::
18512 * GNAT.Float_Control (g-flocon.ads)::
18513 * GNAT.Heap_Sort (g-heasor.ads)::
18514 * GNAT.Heap_Sort_A (g-hesora.ads)::
18515 * GNAT.Heap_Sort_G (g-hesorg.ads)::
18516 * GNAT.HTable (g-htable.ads)::
18517 * GNAT.IO (g-io.ads)::
18518 * GNAT.IO_Aux (g-io_aux.ads)::
18519 * GNAT.Lock_Files (g-locfil.ads)::
18520 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
18521 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
18522 * GNAT.MD5 (g-md5.ads)::
18523 * GNAT.Memory_Dump (g-memdum.ads)::
18524 * GNAT.Most_Recent_Exception (g-moreex.ads)::
18525 * GNAT.OS_Lib (g-os_lib.ads)::
18526 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
18527 * GNAT.Random_Numbers (g-rannum.ads)::
18528 * GNAT.Regexp (g-regexp.ads)::
18529 * GNAT.Registry (g-regist.ads)::
18530 * GNAT.Regpat (g-regpat.ads)::
18531 * GNAT.Rewrite_Data (g-rewdat.ads)::
18532 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
18533 * GNAT.Semaphores (g-semaph.ads)::
18534 * GNAT.Serial_Communications (g-sercom.ads)::
18535 * GNAT.SHA1 (g-sha1.ads)::
18536 * GNAT.SHA224 (g-sha224.ads)::
18537 * GNAT.SHA256 (g-sha256.ads)::
18538 * GNAT.SHA384 (g-sha384.ads)::
18539 * GNAT.SHA512 (g-sha512.ads)::
18540 * GNAT.Signals (g-signal.ads)::
18541 * GNAT.Sockets (g-socket.ads)::
18542 * GNAT.Source_Info (g-souinf.ads)::
18543 * GNAT.Spelling_Checker (g-speche.ads)::
18544 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
18545 * GNAT.Spitbol.Patterns (g-spipat.ads)::
18546 * GNAT.Spitbol (g-spitbo.ads)::
18547 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
18548 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
18549 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
18550 * GNAT.SSE (g-sse.ads)::
18551 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
18552 * GNAT.Strings (g-string.ads)::
18553 * GNAT.String_Split (g-strspl.ads)::
18554 * GNAT.Table (g-table.ads)::
18555 * GNAT.Task_Lock (g-tasloc.ads)::
18556 * GNAT.Threads (g-thread.ads)::
18557 * GNAT.Time_Stamp (g-timsta.ads)::
18558 * GNAT.Traceback (g-traceb.ads)::
18559 * GNAT.Traceback.Symbolic (g-trasym.ads)::
18560 * GNAT.UTF_32 (g-utf_32.ads)::
18561 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
18562 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
18563 * GNAT.Wide_String_Split (g-wistsp.ads)::
18564 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
18565 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
18566 * Interfaces.C.Extensions (i-cexten.ads)::
18567 * Interfaces.C.Streams (i-cstrea.ads)::
18568 * Interfaces.CPP (i-cpp.ads)::
18569 * Interfaces.Packed_Decimal (i-pacdec.ads)::
18570 * Interfaces.VxWorks (i-vxwork.ads)::
18571 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
18572 * System.Address_Image (s-addima.ads)::
18573 * System.Assertions (s-assert.ads)::
18574 * System.Memory (s-memory.ads)::
18575 * System.Multiprocessors (s-multip.ads)::
18576 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
18577 * System.Partition_Interface (s-parint.ads)::
18578 * System.Pool_Global (s-pooglo.ads)::
18579 * System.Pool_Local (s-pooloc.ads)::
18580 * System.Restrictions (s-restri.ads)::
18581 * System.Rident (s-rident.ads)::
18582 * System.Strings.Stream_Ops (s-ststop.ads)::
18583 * System.Unsigned_Types (s-unstyp.ads)::
18584 * System.Wch_Cnv (s-wchcnv.ads)::
18585 * System.Wch_Con (s-wchcon.ads)::
18586 @end menu
18587
18588 @node Ada.Characters.Latin_9 (a-chlat9.ads)
18589 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
18590 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
18591 @cindex Latin_9 constants for Character
18592
18593 @noindent
18594 This child of @code{Ada.Characters}
18595 provides a set of definitions corresponding to those in the
18596 RM-defined package @code{Ada.Characters.Latin_1} but with the
18597 few modifications required for @code{Latin-9}
18598 The provision of such a package
18599 is specifically authorized by the Ada Reference Manual
18600 (RM A.3.3(27)).
18601
18602 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
18603 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
18604 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
18605 @cindex Latin_1 constants for Wide_Character
18606
18607 @noindent
18608 This child of @code{Ada.Characters}
18609 provides a set of definitions corresponding to those in the
18610 RM-defined package @code{Ada.Characters.Latin_1} but with the
18611 types of the constants being @code{Wide_Character}
18612 instead of @code{Character}. The provision of such a package
18613 is specifically authorized by the Ada Reference Manual
18614 (RM A.3.3(27)).
18615
18616 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
18617 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
18618 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
18619 @cindex Latin_9 constants for Wide_Character
18620
18621 @noindent
18622 This child of @code{Ada.Characters}
18623 provides a set of definitions corresponding to those in the
18624 GNAT defined package @code{Ada.Characters.Latin_9} but with the
18625 types of the constants being @code{Wide_Character}
18626 instead of @code{Character}. The provision of such a package
18627 is specifically authorized by the Ada Reference Manual
18628 (RM A.3.3(27)).
18629
18630 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
18631 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
18632 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
18633 @cindex Latin_1 constants for Wide_Wide_Character
18634
18635 @noindent
18636 This child of @code{Ada.Characters}
18637 provides a set of definitions corresponding to those in the
18638 RM-defined package @code{Ada.Characters.Latin_1} but with the
18639 types of the constants being @code{Wide_Wide_Character}
18640 instead of @code{Character}. The provision of such a package
18641 is specifically authorized by the Ada Reference Manual
18642 (RM A.3.3(27)).
18643
18644 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
18645 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
18646 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
18647 @cindex Latin_9 constants for Wide_Wide_Character
18648
18649 @noindent
18650 This child of @code{Ada.Characters}
18651 provides a set of definitions corresponding to those in the
18652 GNAT defined package @code{Ada.Characters.Latin_9} but with the
18653 types of the constants being @code{Wide_Wide_Character}
18654 instead of @code{Character}. The provision of such a package
18655 is specifically authorized by the Ada Reference Manual
18656 (RM A.3.3(27)).
18657
18658 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
18659 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
18660 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
18661 @cindex Formal container for doubly linked lists
18662
18663 @noindent
18664 This child of @code{Ada.Containers} defines a modified version of the
18665 Ada 2005 container for doubly linked lists, meant to facilitate formal
18666 verification of code using such containers. The specification of this
18667 unit is compatible with SPARK 2014.
18668
18669 Note that although this container was designed with formal verification
18670 in mind, it may well be generally useful in that it is a simplified more
18671 efficient version than the one defined in the standard. In particular it
18672 does not have the complex overhead required to detect cursor tampering.
18673
18674 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
18675 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
18676 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
18677 @cindex Formal container for hashed maps
18678
18679 @noindent
18680 This child of @code{Ada.Containers} defines a modified version of the
18681 Ada 2005 container for hashed maps, meant to facilitate formal
18682 verification of code using such containers. The specification of this
18683 unit is compatible with SPARK 2014.
18684
18685 Note that although this container was designed with formal verification
18686 in mind, it may well be generally useful in that it is a simplified more
18687 efficient version than the one defined in the standard. In particular it
18688 does not have the complex overhead required to detect cursor tampering.
18689
18690 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
18691 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
18692 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
18693 @cindex Formal container for hashed sets
18694
18695 @noindent
18696 This child of @code{Ada.Containers} defines a modified version of the
18697 Ada 2005 container for hashed sets, meant to facilitate formal
18698 verification of code using such containers. The specification of this
18699 unit is compatible with SPARK 2014.
18700
18701 Note that although this container was designed with formal verification
18702 in mind, it may well be generally useful in that it is a simplified more
18703 efficient version than the one defined in the standard. In particular it
18704 does not have the complex overhead required to detect cursor tampering.
18705
18706 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
18707 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
18708 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
18709 @cindex Formal container for ordered maps
18710
18711 @noindent
18712 This child of @code{Ada.Containers} defines a modified version of the
18713 Ada 2005 container for ordered maps, meant to facilitate formal
18714 verification of code using such containers. The specification of this
18715 unit is compatible with SPARK 2014.
18716
18717 Note that although this container was designed with formal verification
18718 in mind, it may well be generally useful in that it is a simplified more
18719 efficient version than the one defined in the standard. In particular it
18720 does not have the complex overhead required to detect cursor tampering.
18721
18722 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
18723 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
18724 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
18725 @cindex Formal container for ordered sets
18726
18727 @noindent
18728 This child of @code{Ada.Containers} defines a modified version of the
18729 Ada 2005 container for ordered sets, meant to facilitate formal
18730 verification of code using such containers. The specification of this
18731 unit is compatible with SPARK 2014.
18732
18733 Note that although this container was designed with formal verification
18734 in mind, it may well be generally useful in that it is a simplified more
18735 efficient version than the one defined in the standard. In particular it
18736 does not have the complex overhead required to detect cursor tampering.
18737
18738 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
18739 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
18740 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
18741 @cindex Formal container for vectors
18742
18743 @noindent
18744 This child of @code{Ada.Containers} defines a modified version of the
18745 Ada 2005 container for vectors, meant to facilitate formal
18746 verification of code using such containers. The specification of this
18747 unit is compatible with SPARK 2014.
18748
18749 Note that although this container was designed with formal verification
18750 in mind, it may well be generally useful in that it is a simplified more
18751 efficient version than the one defined in the standard. In particular it
18752 does not have the complex overhead required to detect cursor tampering.
18753
18754 @node Ada.Command_Line.Environment (a-colien.ads)
18755 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
18756 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
18757 @cindex Environment entries
18758
18759 @noindent
18760 This child of @code{Ada.Command_Line}
18761 provides a mechanism for obtaining environment values on systems
18762 where this concept makes sense.
18763
18764 @node Ada.Command_Line.Remove (a-colire.ads)
18765 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
18766 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
18767 @cindex Removing command line arguments
18768 @cindex Command line, argument removal
18769
18770 @noindent
18771 This child of @code{Ada.Command_Line}
18772 provides a mechanism for logically removing
18773 arguments from the argument list. Once removed, an argument is not visible
18774 to further calls on the subprograms in @code{Ada.Command_Line} will not
18775 see the removed argument.
18776
18777 @node Ada.Command_Line.Response_File (a-clrefi.ads)
18778 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
18779 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
18780 @cindex Response file for command line
18781 @cindex Command line, response file
18782 @cindex Command line, handling long command lines
18783
18784 @noindent
18785 This child of @code{Ada.Command_Line} provides a mechanism facilities for
18786 getting command line arguments from a text file, called a "response file".
18787 Using a response file allow passing a set of arguments to an executable longer
18788 than the maximum allowed by the system on the command line.
18789
18790 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
18791 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
18792 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
18793 @cindex C Streams, Interfacing with Direct_IO
18794
18795 @noindent
18796 This package provides subprograms that allow interfacing between
18797 C streams and @code{Direct_IO}. The stream identifier can be
18798 extracted from a file opened on the Ada side, and an Ada file
18799 can be constructed from a stream opened on the C side.
18800
18801 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
18802 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
18803 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
18804 @cindex Null_Occurrence, testing for
18805
18806 @noindent
18807 This child subprogram provides a way of testing for the null
18808 exception occurrence (@code{Null_Occurrence}) without raising
18809 an exception.
18810
18811 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
18812 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
18813 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
18814 @cindex Null_Occurrence, testing for
18815
18816 @noindent
18817 This child subprogram is used for handling otherwise unhandled
18818 exceptions (hence the name last chance), and perform clean ups before
18819 terminating the program. Note that this subprogram never returns.
18820
18821 @node Ada.Exceptions.Traceback (a-exctra.ads)
18822 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
18823 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
18824 @cindex Traceback for Exception Occurrence
18825
18826 @noindent
18827 This child package provides the subprogram (@code{Tracebacks}) to
18828 give a traceback array of addresses based on an exception
18829 occurrence.
18830
18831 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
18832 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
18833 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
18834 @cindex C Streams, Interfacing with Sequential_IO
18835
18836 @noindent
18837 This package provides subprograms that allow interfacing between
18838 C streams and @code{Sequential_IO}. The stream identifier can be
18839 extracted from a file opened on the Ada side, and an Ada file
18840 can be constructed from a stream opened on the C side.
18841
18842 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
18843 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
18844 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
18845 @cindex C Streams, Interfacing with Stream_IO
18846
18847 @noindent
18848 This package provides subprograms that allow interfacing between
18849 C streams and @code{Stream_IO}. The stream identifier can be
18850 extracted from a file opened on the Ada side, and an Ada file
18851 can be constructed from a stream opened on the C side.
18852
18853 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
18854 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
18855 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
18856 @cindex @code{Unbounded_String}, IO support
18857 @cindex @code{Text_IO}, extensions for unbounded strings
18858
18859 @noindent
18860 This package provides subprograms for Text_IO for unbounded
18861 strings, avoiding the necessity for an intermediate operation
18862 with ordinary strings.
18863
18864 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
18865 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
18866 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
18867 @cindex @code{Unbounded_Wide_String}, IO support
18868 @cindex @code{Text_IO}, extensions for unbounded wide strings
18869
18870 @noindent
18871 This package provides subprograms for Text_IO for unbounded
18872 wide strings, avoiding the necessity for an intermediate operation
18873 with ordinary wide strings.
18874
18875 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
18876 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
18877 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
18878 @cindex @code{Unbounded_Wide_Wide_String}, IO support
18879 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
18880
18881 @noindent
18882 This package provides subprograms for Text_IO for unbounded
18883 wide wide strings, avoiding the necessity for an intermediate operation
18884 with ordinary wide wide strings.
18885
18886 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
18887 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
18888 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
18889 @cindex C Streams, Interfacing with @code{Text_IO}
18890
18891 @noindent
18892 This package provides subprograms that allow interfacing between
18893 C streams and @code{Text_IO}. The stream identifier can be
18894 extracted from a file opened on the Ada side, and an Ada file
18895 can be constructed from a stream opened on the C side.
18896
18897 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
18898 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
18899 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
18900 @cindex @code{Text_IO} resetting standard files
18901
18902 @noindent
18903 This procedure is used to reset the status of the standard files used
18904 by Ada.Text_IO. This is useful in a situation (such as a restart in an
18905 embedded application) where the status of the files may change during
18906 execution (for example a standard input file may be redefined to be
18907 interactive).
18908
18909 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
18910 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
18911 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
18912 @cindex Unicode categorization, Wide_Character
18913
18914 @noindent
18915 This package provides subprograms that allow categorization of
18916 Wide_Character values according to Unicode categories.
18917
18918 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
18919 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
18920 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
18921 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
18922
18923 @noindent
18924 This package provides subprograms that allow interfacing between
18925 C streams and @code{Wide_Text_IO}. The stream identifier can be
18926 extracted from a file opened on the Ada side, and an Ada file
18927 can be constructed from a stream opened on the C side.
18928
18929 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
18930 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
18931 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
18932 @cindex @code{Wide_Text_IO} resetting standard files
18933
18934 @noindent
18935 This procedure is used to reset the status of the standard files used
18936 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
18937 embedded application) where the status of the files may change during
18938 execution (for example a standard input file may be redefined to be
18939 interactive).
18940
18941 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
18942 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
18943 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
18944 @cindex Unicode categorization, Wide_Wide_Character
18945
18946 @noindent
18947 This package provides subprograms that allow categorization of
18948 Wide_Wide_Character values according to Unicode categories.
18949
18950 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
18951 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
18952 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
18953 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
18954
18955 @noindent
18956 This package provides subprograms that allow interfacing between
18957 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
18958 extracted from a file opened on the Ada side, and an Ada file
18959 can be constructed from a stream opened on the C side.
18960
18961 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
18962 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
18963 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
18964 @cindex @code{Wide_Wide_Text_IO} resetting standard files
18965
18966 @noindent
18967 This procedure is used to reset the status of the standard files used
18968 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
18969 restart in an embedded application) where the status of the files may
18970 change during execution (for example a standard input file may be
18971 redefined to be interactive).
18972
18973 @node GNAT.Altivec (g-altive.ads)
18974 @section @code{GNAT.Altivec} (@file{g-altive.ads})
18975 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
18976 @cindex AltiVec
18977
18978 @noindent
18979 This is the root package of the GNAT AltiVec binding. It provides
18980 definitions of constants and types common to all the versions of the
18981 binding.
18982
18983 @node GNAT.Altivec.Conversions (g-altcon.ads)
18984 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
18985 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
18986 @cindex AltiVec
18987
18988 @noindent
18989 This package provides the Vector/View conversion routines.
18990
18991 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
18992 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
18993 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
18994 @cindex AltiVec
18995
18996 @noindent
18997 This package exposes the Ada interface to the AltiVec operations on
18998 vector objects. A soft emulation is included by default in the GNAT
18999 library. The hard binding is provided as a separate package. This unit
19000 is common to both bindings.
19001
19002 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
19003 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
19004 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
19005 @cindex AltiVec
19006
19007 @noindent
19008 This package exposes the various vector types part of the Ada binding
19009 to AltiVec facilities.
19010
19011 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
19012 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19013 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19014 @cindex AltiVec
19015
19016 @noindent
19017 This package provides public 'View' data types from/to which private
19018 vector representations can be converted via
19019 GNAT.Altivec.Conversions. This allows convenient access to individual
19020 vector elements and provides a simple way to initialize vector
19021 objects.
19022
19023 @node GNAT.Array_Split (g-arrspl.ads)
19024 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19025 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19026 @cindex Array splitter
19027
19028 @noindent
19029 Useful array-manipulation routines: given a set of separators, split
19030 an array wherever the separators appear, and provide direct access
19031 to the resulting slices.
19032
19033 @node GNAT.AWK (g-awk.ads)
19034 @section @code{GNAT.AWK} (@file{g-awk.ads})
19035 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
19036 @cindex Parsing
19037 @cindex AWK
19038
19039 @noindent
19040 Provides AWK-like parsing functions, with an easy interface for parsing one
19041 or more files containing formatted data. The file is viewed as a database
19042 where each record is a line and a field is a data element in this line.
19043
19044 @node GNAT.Bounded_Buffers (g-boubuf.ads)
19045 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19046 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19047 @cindex Parsing
19048 @cindex Bounded Buffers
19049
19050 @noindent
19051 Provides a concurrent generic bounded buffer abstraction. Instances are
19052 useful directly or as parts of the implementations of other abstractions,
19053 such as mailboxes.
19054
19055 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
19056 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19057 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19058 @cindex Parsing
19059 @cindex Mailboxes
19060
19061 @noindent
19062 Provides a thread-safe asynchronous intertask mailbox communication facility.
19063
19064 @node GNAT.Bubble_Sort (g-bubsor.ads)
19065 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19066 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19067 @cindex Sorting
19068 @cindex Bubble sort
19069
19070 @noindent
19071 Provides a general implementation of bubble sort usable for sorting arbitrary
19072 data items. Exchange and comparison procedures are provided by passing
19073 access-to-procedure values.
19074
19075 @node GNAT.Bubble_Sort_A (g-busora.ads)
19076 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19077 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19078 @cindex Sorting
19079 @cindex Bubble sort
19080
19081 @noindent
19082 Provides a general implementation of bubble sort usable for sorting arbitrary
19083 data items. Move and comparison procedures are provided by passing
19084 access-to-procedure values. This is an older version, retained for
19085 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
19086
19087 @node GNAT.Bubble_Sort_G (g-busorg.ads)
19088 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19089 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19090 @cindex Sorting
19091 @cindex Bubble sort
19092
19093 @noindent
19094 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
19095 are provided as generic parameters, this improves efficiency, especially
19096 if the procedures can be inlined, at the expense of duplicating code for
19097 multiple instantiations.
19098
19099 @node GNAT.Byte_Order_Mark (g-byorma.ads)
19100 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19101 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19102 @cindex UTF-8 representation
19103 @cindex Wide characte representations
19104
19105 @noindent
19106 Provides a routine which given a string, reads the start of the string to
19107 see whether it is one of the standard byte order marks (BOM's) which signal
19108 the encoding of the string. The routine includes detection of special XML
19109 sequences for various UCS input formats.
19110
19111 @node GNAT.Byte_Swapping (g-bytswa.ads)
19112 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19113 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19114 @cindex Byte swapping
19115 @cindex Endianness
19116
19117 @noindent
19118 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
19119 Machine-specific implementations are available in some cases.
19120
19121 @node GNAT.Calendar (g-calend.ads)
19122 @section @code{GNAT.Calendar} (@file{g-calend.ads})
19123 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
19124 @cindex @code{Calendar}
19125
19126 @noindent
19127 Extends the facilities provided by @code{Ada.Calendar} to include handling
19128 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
19129 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
19130 C @code{timeval} format.
19131
19132 @node GNAT.Calendar.Time_IO (g-catiio.ads)
19133 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19134 @cindex @code{Calendar}
19135 @cindex Time
19136 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19137
19138 @node GNAT.CRC32 (g-crc32.ads)
19139 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
19140 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
19141 @cindex CRC32
19142 @cindex Cyclic Redundancy Check
19143
19144 @noindent
19145 This package implements the CRC-32 algorithm. For a full description
19146 of this algorithm see
19147 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
19148 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
19149 Aug.@: 1988. Sarwate, D.V@.
19150
19151 @node GNAT.Case_Util (g-casuti.ads)
19152 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
19153 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
19154 @cindex Casing utilities
19155 @cindex Character handling (@code{GNAT.Case_Util})
19156
19157 @noindent
19158 A set of simple routines for handling upper and lower casing of strings
19159 without the overhead of the full casing tables
19160 in @code{Ada.Characters.Handling}.
19161
19162 @node GNAT.CGI (g-cgi.ads)
19163 @section @code{GNAT.CGI} (@file{g-cgi.ads})
19164 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
19165 @cindex CGI (Common Gateway Interface)
19166
19167 @noindent
19168 This is a package for interfacing a GNAT program with a Web server via the
19169 Common Gateway Interface (CGI)@. Basically this package parses the CGI
19170 parameters, which are a set of key/value pairs sent by the Web server. It
19171 builds a table whose index is the key and provides some services to deal
19172 with this table.
19173
19174 @node GNAT.CGI.Cookie (g-cgicoo.ads)
19175 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19176 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19177 @cindex CGI (Common Gateway Interface) cookie support
19178 @cindex Cookie support in CGI
19179
19180 @noindent
19181 This is a package to interface a GNAT program with a Web server via the
19182 Common Gateway Interface (CGI). It exports services to deal with Web
19183 cookies (piece of information kept in the Web client software).
19184
19185 @node GNAT.CGI.Debug (g-cgideb.ads)
19186 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19187 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19188 @cindex CGI (Common Gateway Interface) debugging
19189
19190 @noindent
19191 This is a package to help debugging CGI (Common Gateway Interface)
19192 programs written in Ada.
19193
19194 @node GNAT.Command_Line (g-comlin.ads)
19195 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
19196 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
19197 @cindex Command line
19198
19199 @noindent
19200 Provides a high level interface to @code{Ada.Command_Line} facilities,
19201 including the ability to scan for named switches with optional parameters
19202 and expand file names using wild card notations.
19203
19204 @node GNAT.Compiler_Version (g-comver.ads)
19205 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19206 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19207 @cindex Compiler Version
19208 @cindex Version, of compiler
19209
19210 @noindent
19211 Provides a routine for obtaining the version of the compiler used to
19212 compile the program. More accurately this is the version of the binder
19213 used to bind the program (this will normally be the same as the version
19214 of the compiler if a consistent tool set is used to compile all units
19215 of a partition).
19216
19217 @node GNAT.Ctrl_C (g-ctrl_c.ads)
19218 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19219 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19220 @cindex Interrupt
19221
19222 @noindent
19223 Provides a simple interface to handle Ctrl-C keyboard events.
19224
19225 @node GNAT.Current_Exception (g-curexc.ads)
19226 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19227 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19228 @cindex Current exception
19229 @cindex Exception retrieval
19230
19231 @noindent
19232 Provides access to information on the current exception that has been raised
19233 without the need for using the Ada 95 / Ada 2005 exception choice parameter
19234 specification syntax.
19235 This is particularly useful in simulating typical facilities for
19236 obtaining information about exceptions provided by Ada 83 compilers.
19237
19238 @node GNAT.Debug_Pools (g-debpoo.ads)
19239 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19240 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19241 @cindex Debugging
19242 @cindex Debug pools
19243 @cindex Memory corruption debugging
19244
19245 @noindent
19246 Provide a debugging storage pools that helps tracking memory corruption
19247 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
19248 @value{EDITION} User's Guide}.
19249
19250 @node GNAT.Debug_Utilities (g-debuti.ads)
19251 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19252 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19253 @cindex Debugging
19254
19255 @noindent
19256 Provides a few useful utilities for debugging purposes, including conversion
19257 to and from string images of address values. Supports both C and Ada formats
19258 for hexadecimal literals.
19259
19260 @node GNAT.Decode_String (g-decstr.ads)
19261 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
19262 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
19263 @cindex Decoding strings
19264 @cindex String decoding
19265 @cindex Wide character encoding
19266 @cindex UTF-8
19267 @cindex Unicode
19268
19269 @noindent
19270 A generic package providing routines for decoding wide character and wide wide
19271 character strings encoded as sequences of 8-bit characters using a specified
19272 encoding method. Includes validation routines, and also routines for stepping
19273 to next or previous encoded character in an encoded string.
19274 Useful in conjunction with Unicode character coding. Note there is a
19275 preinstantiation for UTF-8. See next entry.
19276
19277 @node GNAT.Decode_UTF8_String (g-deutst.ads)
19278 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19279 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19280 @cindex Decoding strings
19281 @cindex Decoding UTF-8 strings
19282 @cindex UTF-8 string decoding
19283 @cindex Wide character decoding
19284 @cindex UTF-8
19285 @cindex Unicode
19286
19287 @noindent
19288 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
19289
19290 @node GNAT.Directory_Operations (g-dirope.ads)
19291 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19292 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19293 @cindex Directory operations
19294
19295 @noindent
19296 Provides a set of routines for manipulating directories, including changing
19297 the current directory, making new directories, and scanning the files in a
19298 directory.
19299
19300 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
19301 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19302 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19303 @cindex Directory operations iteration
19304
19305 @noindent
19306 A child unit of GNAT.Directory_Operations providing additional operations
19307 for iterating through directories.
19308
19309 @node GNAT.Dynamic_HTables (g-dynhta.ads)
19310 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19311 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19312 @cindex Hash tables
19313
19314 @noindent
19315 A generic implementation of hash tables that can be used to hash arbitrary
19316 data. Provided in two forms, a simple form with built in hash functions,
19317 and a more complex form in which the hash function is supplied.
19318
19319 @noindent
19320 This package provides a facility similar to that of @code{GNAT.HTable},
19321 except that this package declares a type that can be used to define
19322 dynamic instances of the hash table, while an instantiation of
19323 @code{GNAT.HTable} creates a single instance of the hash table.
19324
19325 @node GNAT.Dynamic_Tables (g-dyntab.ads)
19326 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19327 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19328 @cindex Table implementation
19329 @cindex Arrays, extendable
19330
19331 @noindent
19332 A generic package providing a single dimension array abstraction where the
19333 length of the array can be dynamically modified.
19334
19335 @noindent
19336 This package provides a facility similar to that of @code{GNAT.Table},
19337 except that this package declares a type that can be used to define
19338 dynamic instances of the table, while an instantiation of
19339 @code{GNAT.Table} creates a single instance of the table type.
19340
19341 @node GNAT.Encode_String (g-encstr.ads)
19342 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
19343 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
19344 @cindex Encoding strings
19345 @cindex String encoding
19346 @cindex Wide character encoding
19347 @cindex UTF-8
19348 @cindex Unicode
19349
19350 @noindent
19351 A generic package providing routines for encoding wide character and wide
19352 wide character strings as sequences of 8-bit characters using a specified
19353 encoding method. Useful in conjunction with Unicode character coding.
19354 Note there is a preinstantiation for UTF-8. See next entry.
19355
19356 @node GNAT.Encode_UTF8_String (g-enutst.ads)
19357 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19358 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19359 @cindex Encoding strings
19360 @cindex Encoding UTF-8 strings
19361 @cindex UTF-8 string encoding
19362 @cindex Wide character encoding
19363 @cindex UTF-8
19364 @cindex Unicode
19365
19366 @noindent
19367 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
19368
19369 @node GNAT.Exception_Actions (g-excact.ads)
19370 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19371 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19372 @cindex Exception actions
19373
19374 @noindent
19375 Provides callbacks when an exception is raised. Callbacks can be registered
19376 for specific exceptions, or when any exception is raised. This
19377 can be used for instance to force a core dump to ease debugging.
19378
19379 @node GNAT.Exception_Traces (g-exctra.ads)
19380 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19381 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19382 @cindex Exception traces
19383 @cindex Debugging
19384
19385 @noindent
19386 Provides an interface allowing to control automatic output upon exception
19387 occurrences.
19388
19389 @node GNAT.Exceptions (g-except.ads)
19390 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
19391 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
19392 @cindex Exceptions, Pure
19393 @cindex Pure packages, exceptions
19394
19395 @noindent
19396 Normally it is not possible to raise an exception with
19397 a message from a subprogram in a pure package, since the
19398 necessary types and subprograms are in @code{Ada.Exceptions}
19399 which is not a pure unit. @code{GNAT.Exceptions} provides a
19400 facility for getting around this limitation for a few
19401 predefined exceptions, and for example allow raising
19402 @code{Constraint_Error} with a message from a pure subprogram.
19403
19404 @node GNAT.Expect (g-expect.ads)
19405 @section @code{GNAT.Expect} (@file{g-expect.ads})
19406 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
19407
19408 @noindent
19409 Provides a set of subprograms similar to what is available
19410 with the standard Tcl Expect tool.
19411 It allows you to easily spawn and communicate with an external process.
19412 You can send commands or inputs to the process, and compare the output
19413 with some expected regular expression. Currently @code{GNAT.Expect}
19414 is implemented on all native GNAT ports except for OpenVMS@.
19415 It is not implemented for cross ports, and in particular is not
19416 implemented for VxWorks or LynxOS@.
19417
19418 @node GNAT.Expect.TTY (g-exptty.ads)
19419 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
19420 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
19421
19422 @noindent
19423 As GNAT.Expect but using pseudo-terminal.
19424 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
19425 ports except for OpenVMS@. It is not implemented for cross ports, and
19426 in particular is not implemented for VxWorks or LynxOS@.
19427
19428 @node GNAT.Float_Control (g-flocon.ads)
19429 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
19430 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
19431 @cindex Floating-Point Processor
19432
19433 @noindent
19434 Provides an interface for resetting the floating-point processor into the
19435 mode required for correct semantic operation in Ada. Some third party
19436 library calls may cause this mode to be modified, and the Reset procedure
19437 in this package can be used to reestablish the required mode.
19438
19439 @node GNAT.Heap_Sort (g-heasor.ads)
19440 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
19441 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
19442 @cindex Sorting
19443
19444 @noindent
19445 Provides a general implementation of heap sort usable for sorting arbitrary
19446 data items. Exchange and comparison procedures are provided by passing
19447 access-to-procedure values. The algorithm used is a modified heap sort
19448 that performs approximately N*log(N) comparisons in the worst case.
19449
19450 @node GNAT.Heap_Sort_A (g-hesora.ads)
19451 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
19452 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
19453 @cindex Sorting
19454
19455 @noindent
19456 Provides a general implementation of heap sort usable for sorting arbitrary
19457 data items. Move and comparison procedures are provided by passing
19458 access-to-procedure values. The algorithm used is a modified heap sort
19459 that performs approximately N*log(N) comparisons in the worst case.
19460 This differs from @code{GNAT.Heap_Sort} in having a less convenient
19461 interface, but may be slightly more efficient.
19462
19463 @node GNAT.Heap_Sort_G (g-hesorg.ads)
19464 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
19465 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
19466 @cindex Sorting
19467
19468 @noindent
19469 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
19470 are provided as generic parameters, this improves efficiency, especially
19471 if the procedures can be inlined, at the expense of duplicating code for
19472 multiple instantiations.
19473
19474 @node GNAT.HTable (g-htable.ads)
19475 @section @code{GNAT.HTable} (@file{g-htable.ads})
19476 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
19477 @cindex Hash tables
19478
19479 @noindent
19480 A generic implementation of hash tables that can be used to hash arbitrary
19481 data. Provides two approaches, one a simple static approach, and the other
19482 allowing arbitrary dynamic hash tables.
19483
19484 @node GNAT.IO (g-io.ads)
19485 @section @code{GNAT.IO} (@file{g-io.ads})
19486 @cindex @code{GNAT.IO} (@file{g-io.ads})
19487 @cindex Simple I/O
19488 @cindex Input/Output facilities
19489
19490 @noindent
19491 A simple preelaborable input-output package that provides a subset of
19492 simple Text_IO functions for reading characters and strings from
19493 Standard_Input, and writing characters, strings and integers to either
19494 Standard_Output or Standard_Error.
19495
19496 @node GNAT.IO_Aux (g-io_aux.ads)
19497 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
19498 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
19499 @cindex Text_IO
19500 @cindex Input/Output facilities
19501
19502 Provides some auxiliary functions for use with Text_IO, including a test
19503 for whether a file exists, and functions for reading a line of text.
19504
19505 @node GNAT.Lock_Files (g-locfil.ads)
19506 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
19507 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
19508 @cindex File locking
19509 @cindex Locking using files
19510
19511 @noindent
19512 Provides a general interface for using files as locks. Can be used for
19513 providing program level synchronization.
19514
19515 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
19516 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
19517 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
19518 @cindex Random number generation
19519
19520 @noindent
19521 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
19522 a modified version of the Blum-Blum-Shub generator.
19523
19524 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
19525 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
19526 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
19527 @cindex Random number generation
19528
19529 @noindent
19530 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
19531 a modified version of the Blum-Blum-Shub generator.
19532
19533 @node GNAT.MD5 (g-md5.ads)
19534 @section @code{GNAT.MD5} (@file{g-md5.ads})
19535 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
19536 @cindex Message Digest MD5
19537
19538 @noindent
19539 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
19540
19541 @node GNAT.Memory_Dump (g-memdum.ads)
19542 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
19543 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
19544 @cindex Dump Memory
19545
19546 @noindent
19547 Provides a convenient routine for dumping raw memory to either the
19548 standard output or standard error files. Uses GNAT.IO for actual
19549 output.
19550
19551 @node GNAT.Most_Recent_Exception (g-moreex.ads)
19552 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
19553 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
19554 @cindex Exception, obtaining most recent
19555
19556 @noindent
19557 Provides access to the most recently raised exception. Can be used for
19558 various logging purposes, including duplicating functionality of some
19559 Ada 83 implementation dependent extensions.
19560
19561 @node GNAT.OS_Lib (g-os_lib.ads)
19562 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
19563 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
19564 @cindex Operating System interface
19565 @cindex Spawn capability
19566
19567 @noindent
19568 Provides a range of target independent operating system interface functions,
19569 including time/date management, file operations, subprocess management,
19570 including a portable spawn procedure, and access to environment variables
19571 and error return codes.
19572
19573 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
19574 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
19575 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
19576 @cindex Hash functions
19577
19578 @noindent
19579 Provides a generator of static minimal perfect hash functions. No
19580 collisions occur and each item can be retrieved from the table in one
19581 probe (perfect property). The hash table size corresponds to the exact
19582 size of the key set and no larger (minimal property). The key set has to
19583 be know in advance (static property). The hash functions are also order
19584 preserving. If w2 is inserted after w1 in the generator, their
19585 hashcode are in the same order. These hashing functions are very
19586 convenient for use with realtime applications.
19587
19588 @node GNAT.Random_Numbers (g-rannum.ads)
19589 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
19590 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
19591 @cindex Random number generation
19592
19593 @noindent
19594 Provides random number capabilities which extend those available in the
19595 standard Ada library and are more convenient to use.
19596
19597 @node GNAT.Regexp (g-regexp.ads)
19598 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
19599 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
19600 @cindex Regular expressions
19601 @cindex Pattern matching
19602
19603 @noindent
19604 A simple implementation of regular expressions, using a subset of regular
19605 expression syntax copied from familiar Unix style utilities. This is the
19606 simplest of the three pattern matching packages provided, and is particularly
19607 suitable for ``file globbing'' applications.
19608
19609 @node GNAT.Registry (g-regist.ads)
19610 @section @code{GNAT.Registry} (@file{g-regist.ads})
19611 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
19612 @cindex Windows Registry
19613
19614 @noindent
19615 This is a high level binding to the Windows registry. It is possible to
19616 do simple things like reading a key value, creating a new key. For full
19617 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
19618 package provided with the Win32Ada binding
19619
19620 @node GNAT.Regpat (g-regpat.ads)
19621 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
19622 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
19623 @cindex Regular expressions
19624 @cindex Pattern matching
19625
19626 @noindent
19627 A complete implementation of Unix-style regular expression matching, copied
19628 from the original V7 style regular expression library written in C by
19629 Henry Spencer (and binary compatible with this C library).
19630
19631 @node GNAT.Rewrite_Data (g-rewdat.ads)
19632 @section @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
19633 @cindex @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
19634 @cindex Rewrite data
19635
19636 @noindent
19637 A unit to rewrite on-the-fly string occurrences in a stream of
19638 data. The implementation has a very minimal memory footprint as the
19639 full content to be processed is not loaded into memory all at once. This makes
19640 this interface usable for large files or socket streams.
19641
19642 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
19643 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
19644 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
19645 @cindex Secondary Stack Info
19646
19647 @noindent
19648 Provide the capability to query the high water mark of the current task's
19649 secondary stack.
19650
19651 @node GNAT.Semaphores (g-semaph.ads)
19652 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
19653 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
19654 @cindex Semaphores
19655
19656 @noindent
19657 Provides classic counting and binary semaphores using protected types.
19658
19659 @node GNAT.Serial_Communications (g-sercom.ads)
19660 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
19661 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
19662 @cindex Serial_Communications
19663
19664 @noindent
19665 Provides a simple interface to send and receive data over a serial
19666 port. This is only supported on GNU/Linux and Windows.
19667
19668 @node GNAT.SHA1 (g-sha1.ads)
19669 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
19670 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
19671 @cindex Secure Hash Algorithm SHA-1
19672
19673 @noindent
19674 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
19675 and RFC 3174.
19676
19677 @node GNAT.SHA224 (g-sha224.ads)
19678 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
19679 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
19680 @cindex Secure Hash Algorithm SHA-224
19681
19682 @noindent
19683 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
19684
19685 @node GNAT.SHA256 (g-sha256.ads)
19686 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
19687 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
19688 @cindex Secure Hash Algorithm SHA-256
19689
19690 @noindent
19691 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
19692
19693 @node GNAT.SHA384 (g-sha384.ads)
19694 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
19695 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
19696 @cindex Secure Hash Algorithm SHA-384
19697
19698 @noindent
19699 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
19700
19701 @node GNAT.SHA512 (g-sha512.ads)
19702 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
19703 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
19704 @cindex Secure Hash Algorithm SHA-512
19705
19706 @noindent
19707 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
19708
19709 @node GNAT.Signals (g-signal.ads)
19710 @section @code{GNAT.Signals} (@file{g-signal.ads})
19711 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
19712 @cindex Signals
19713
19714 @noindent
19715 Provides the ability to manipulate the blocked status of signals on supported
19716 targets.
19717
19718 @node GNAT.Sockets (g-socket.ads)
19719 @section @code{GNAT.Sockets} (@file{g-socket.ads})
19720 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
19721 @cindex Sockets
19722
19723 @noindent
19724 A high level and portable interface to develop sockets based applications.
19725 This package is based on the sockets thin binding found in
19726 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
19727 on all native GNAT ports except for OpenVMS@. It is not implemented
19728 for the LynxOS@ cross port.
19729
19730 @node GNAT.Source_Info (g-souinf.ads)
19731 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
19732 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
19733 @cindex Source Information
19734
19735 @noindent
19736 Provides subprograms that give access to source code information known at
19737 compile time, such as the current file name and line number.
19738
19739 @node GNAT.Spelling_Checker (g-speche.ads)
19740 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
19741 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
19742 @cindex Spell checking
19743
19744 @noindent
19745 Provides a function for determining whether one string is a plausible
19746 near misspelling of another string.
19747
19748 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
19749 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
19750 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
19751 @cindex Spell checking
19752
19753 @noindent
19754 Provides a generic function that can be instantiated with a string type for
19755 determining whether one string is a plausible near misspelling of another
19756 string.
19757
19758 @node GNAT.Spitbol.Patterns (g-spipat.ads)
19759 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
19760 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
19761 @cindex SPITBOL pattern matching
19762 @cindex Pattern matching
19763
19764 @noindent
19765 A complete implementation of SNOBOL4 style pattern matching. This is the
19766 most elaborate of the pattern matching packages provided. It fully duplicates
19767 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
19768 efficient algorithm developed by Robert Dewar for the SPITBOL system.
19769
19770 @node GNAT.Spitbol (g-spitbo.ads)
19771 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
19772 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
19773 @cindex SPITBOL interface
19774
19775 @noindent
19776 The top level package of the collection of SPITBOL-style functionality, this
19777 package provides basic SNOBOL4 string manipulation functions, such as
19778 Pad, Reverse, Trim, Substr capability, as well as a generic table function
19779 useful for constructing arbitrary mappings from strings in the style of
19780 the SNOBOL4 TABLE function.
19781
19782 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
19783 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
19784 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
19785 @cindex Sets of strings
19786 @cindex SPITBOL Tables
19787
19788 @noindent
19789 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
19790 for type @code{Standard.Boolean}, giving an implementation of sets of
19791 string values.
19792
19793 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
19794 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
19795 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
19796 @cindex Integer maps
19797 @cindex Maps
19798 @cindex SPITBOL Tables
19799
19800 @noindent
19801 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
19802 for type @code{Standard.Integer}, giving an implementation of maps
19803 from string to integer values.
19804
19805 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
19806 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
19807 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
19808 @cindex String maps
19809 @cindex Maps
19810 @cindex SPITBOL Tables
19811
19812 @noindent
19813 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
19814 a variable length string type, giving an implementation of general
19815 maps from strings to strings.
19816
19817 @node GNAT.SSE (g-sse.ads)
19818 @section @code{GNAT.SSE} (@file{g-sse.ads})
19819 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
19820
19821 @noindent
19822 Root of a set of units aimed at offering Ada bindings to a subset of
19823 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
19824 targets. It exposes vector component types together with a general
19825 introduction to the binding contents and use.
19826
19827 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
19828 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
19829 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
19830
19831 @noindent
19832 SSE vector types for use with SSE related intrinsics.
19833
19834 @node GNAT.Strings (g-string.ads)
19835 @section @code{GNAT.Strings} (@file{g-string.ads})
19836 @cindex @code{GNAT.Strings} (@file{g-string.ads})
19837
19838 @noindent
19839 Common String access types and related subprograms. Basically it
19840 defines a string access and an array of string access types.
19841
19842 @node GNAT.String_Split (g-strspl.ads)
19843 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
19844 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
19845 @cindex String splitter
19846
19847 @noindent
19848 Useful string manipulation routines: given a set of separators, split
19849 a string wherever the separators appear, and provide direct access
19850 to the resulting slices. This package is instantiated from
19851 @code{GNAT.Array_Split}.
19852
19853 @node GNAT.Table (g-table.ads)
19854 @section @code{GNAT.Table} (@file{g-table.ads})
19855 @cindex @code{GNAT.Table} (@file{g-table.ads})
19856 @cindex Table implementation
19857 @cindex Arrays, extendable
19858
19859 @noindent
19860 A generic package providing a single dimension array abstraction where the
19861 length of the array can be dynamically modified.
19862
19863 @noindent
19864 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
19865 except that this package declares a single instance of the table type,
19866 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
19867 used to define dynamic instances of the table.
19868
19869 @node GNAT.Task_Lock (g-tasloc.ads)
19870 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
19871 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
19872 @cindex Task synchronization
19873 @cindex Task locking
19874 @cindex Locking
19875
19876 @noindent
19877 A very simple facility for locking and unlocking sections of code using a
19878 single global task lock. Appropriate for use in situations where contention
19879 between tasks is very rarely expected.
19880
19881 @node GNAT.Time_Stamp (g-timsta.ads)
19882 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
19883 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
19884 @cindex Time stamp
19885 @cindex Current time
19886
19887 @noindent
19888 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
19889 represents the current date and time in ISO 8601 format. This is a very simple
19890 routine with minimal code and there are no dependencies on any other unit.
19891
19892 @node GNAT.Threads (g-thread.ads)
19893 @section @code{GNAT.Threads} (@file{g-thread.ads})
19894 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
19895 @cindex Foreign threads
19896 @cindex Threads, foreign
19897
19898 @noindent
19899 Provides facilities for dealing with foreign threads which need to be known
19900 by the GNAT run-time system. Consult the documentation of this package for
19901 further details if your program has threads that are created by a non-Ada
19902 environment which then accesses Ada code.
19903
19904 @node GNAT.Traceback (g-traceb.ads)
19905 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
19906 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
19907 @cindex Trace back facilities
19908
19909 @noindent
19910 Provides a facility for obtaining non-symbolic traceback information, useful
19911 in various debugging situations.
19912
19913 @node GNAT.Traceback.Symbolic (g-trasym.ads)
19914 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
19915 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
19916 @cindex Trace back facilities
19917
19918 @node GNAT.UTF_32 (g-utf_32.ads)
19919 @section @code{GNAT.UTF_32} (@file{g-table.ads})
19920 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
19921 @cindex Wide character codes
19922
19923 @noindent
19924 This is a package intended to be used in conjunction with the
19925 @code{Wide_Character} type in Ada 95 and the
19926 @code{Wide_Wide_Character} type in Ada 2005 (available
19927 in @code{GNAT} in Ada 2005 mode). This package contains
19928 Unicode categorization routines, as well as lexical
19929 categorization routines corresponding to the Ada 2005
19930 lexical rules for identifiers and strings, and also a
19931 lower case to upper case fold routine corresponding to
19932 the Ada 2005 rules for identifier equivalence.
19933
19934 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
19935 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
19936 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
19937 @cindex Spell checking
19938
19939 @noindent
19940 Provides a function for determining whether one wide wide string is a plausible
19941 near misspelling of another wide wide string, where the strings are represented
19942 using the UTF_32_String type defined in System.Wch_Cnv.
19943
19944 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
19945 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
19946 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
19947 @cindex Spell checking
19948
19949 @noindent
19950 Provides a function for determining whether one wide string is a plausible
19951 near misspelling of another wide string.
19952
19953 @node GNAT.Wide_String_Split (g-wistsp.ads)
19954 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
19955 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
19956 @cindex Wide_String splitter
19957
19958 @noindent
19959 Useful wide string manipulation routines: given a set of separators, split
19960 a wide string wherever the separators appear, and provide direct access
19961 to the resulting slices. This package is instantiated from
19962 @code{GNAT.Array_Split}.
19963
19964 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
19965 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
19966 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
19967 @cindex Spell checking
19968
19969 @noindent
19970 Provides a function for determining whether one wide wide string is a plausible
19971 near misspelling of another wide wide string.
19972
19973 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
19974 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
19975 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
19976 @cindex Wide_Wide_String splitter
19977
19978 @noindent
19979 Useful wide wide string manipulation routines: given a set of separators, split
19980 a wide wide string wherever the separators appear, and provide direct access
19981 to the resulting slices. This package is instantiated from
19982 @code{GNAT.Array_Split}.
19983
19984 @node Interfaces.C.Extensions (i-cexten.ads)
19985 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
19986 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
19987
19988 @noindent
19989 This package contains additional C-related definitions, intended
19990 for use with either manually or automatically generated bindings
19991 to C libraries.
19992
19993 @node Interfaces.C.Streams (i-cstrea.ads)
19994 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
19995 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
19996 @cindex C streams, interfacing
19997
19998 @noindent
19999 This package is a binding for the most commonly used operations
20000 on C streams.
20001
20002 @node Interfaces.CPP (i-cpp.ads)
20003 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
20004 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
20005 @cindex C++ interfacing
20006 @cindex Interfacing, to C++
20007
20008 @noindent
20009 This package provides facilities for use in interfacing to C++. It
20010 is primarily intended to be used in connection with automated tools
20011 for the generation of C++ interfaces.
20012
20013 @node Interfaces.Packed_Decimal (i-pacdec.ads)
20014 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20015 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20016 @cindex IBM Packed Format
20017 @cindex Packed Decimal
20018
20019 @noindent
20020 This package provides a set of routines for conversions to and
20021 from a packed decimal format compatible with that used on IBM
20022 mainframes.
20023
20024 @node Interfaces.VxWorks (i-vxwork.ads)
20025 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20026 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20027 @cindex Interfacing to VxWorks
20028 @cindex VxWorks, interfacing
20029
20030 @noindent
20031 This package provides a limited binding to the VxWorks API.
20032 In particular, it interfaces with the
20033 VxWorks hardware interrupt facilities.
20034
20035 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
20036 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20037 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20038 @cindex Interfacing to VxWorks' I/O
20039 @cindex VxWorks, I/O interfacing
20040 @cindex VxWorks, Get_Immediate
20041 @cindex Get_Immediate, VxWorks
20042
20043 @noindent
20044 This package provides a binding to the ioctl (IO/Control)
20045 function of VxWorks, defining a set of option values and
20046 function codes. A particular use of this package is
20047 to enable the use of Get_Immediate under VxWorks.
20048
20049 @node System.Address_Image (s-addima.ads)
20050 @section @code{System.Address_Image} (@file{s-addima.ads})
20051 @cindex @code{System.Address_Image} (@file{s-addima.ads})
20052 @cindex Address image
20053 @cindex Image, of an address
20054
20055 @noindent
20056 This function provides a useful debugging
20057 function that gives an (implementation dependent)
20058 string which identifies an address.
20059
20060 @node System.Assertions (s-assert.ads)
20061 @section @code{System.Assertions} (@file{s-assert.ads})
20062 @cindex @code{System.Assertions} (@file{s-assert.ads})
20063 @cindex Assertions
20064 @cindex Assert_Failure, exception
20065
20066 @noindent
20067 This package provides the declaration of the exception raised
20068 by an run-time assertion failure, as well as the routine that
20069 is used internally to raise this assertion.
20070
20071 @node System.Memory (s-memory.ads)
20072 @section @code{System.Memory} (@file{s-memory.ads})
20073 @cindex @code{System.Memory} (@file{s-memory.ads})
20074 @cindex Memory allocation
20075
20076 @noindent
20077 This package provides the interface to the low level routines used
20078 by the generated code for allocation and freeing storage for the
20079 default storage pool (analogous to the C routines malloc and free.
20080 It also provides a reallocation interface analogous to the C routine
20081 realloc. The body of this unit may be modified to provide alternative
20082 allocation mechanisms for the default pool, and in addition, direct
20083 calls to this unit may be made for low level allocation uses (for
20084 example see the body of @code{GNAT.Tables}).
20085
20086 @node System.Multiprocessors (s-multip.ads)
20087 @section @code{System.Multiprocessors} (@file{s-multip.ads})
20088 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
20089 @cindex Multiprocessor interface
20090 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20091 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20092 technically an implementation-defined addition).
20093
20094 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
20095 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20096 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20097 @cindex Multiprocessor interface
20098 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20099 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20100 technically an implementation-defined addition).
20101
20102 @node System.Partition_Interface (s-parint.ads)
20103 @section @code{System.Partition_Interface} (@file{s-parint.ads})
20104 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
20105 @cindex Partition interfacing functions
20106
20107 @noindent
20108 This package provides facilities for partition interfacing. It
20109 is used primarily in a distribution context when using Annex E
20110 with @code{GLADE}.
20111
20112 @node System.Pool_Global (s-pooglo.ads)
20113 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
20114 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
20115 @cindex Storage pool, global
20116 @cindex Global storage pool
20117
20118 @noindent
20119 This package provides a storage pool that is equivalent to the default
20120 storage pool used for access types for which no pool is specifically
20121 declared. It uses malloc/free to allocate/free and does not attempt to
20122 do any automatic reclamation.
20123
20124 @node System.Pool_Local (s-pooloc.ads)
20125 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
20126 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
20127 @cindex Storage pool, local
20128 @cindex Local storage pool
20129
20130 @noindent
20131 This package provides a storage pool that is intended for use with locally
20132 defined access types. It uses malloc/free for allocate/free, and maintains
20133 a list of allocated blocks, so that all storage allocated for the pool can
20134 be freed automatically when the pool is finalized.
20135
20136 @node System.Restrictions (s-restri.ads)
20137 @section @code{System.Restrictions} (@file{s-restri.ads})
20138 @cindex @code{System.Restrictions} (@file{s-restri.ads})
20139 @cindex Run-time restrictions access
20140
20141 @noindent
20142 This package provides facilities for accessing at run time
20143 the status of restrictions specified at compile time for
20144 the partition. Information is available both with regard
20145 to actual restrictions specified, and with regard to
20146 compiler determined information on which restrictions
20147 are violated by one or more packages in the partition.
20148
20149 @node System.Rident (s-rident.ads)
20150 @section @code{System.Rident} (@file{s-rident.ads})
20151 @cindex @code{System.Rident} (@file{s-rident.ads})
20152 @cindex Restrictions definitions
20153
20154 @noindent
20155 This package provides definitions of the restrictions
20156 identifiers supported by GNAT, and also the format of
20157 the restrictions provided in package System.Restrictions.
20158 It is not normally necessary to @code{with} this generic package
20159 since the necessary instantiation is included in
20160 package System.Restrictions.
20161
20162 @node System.Strings.Stream_Ops (s-ststop.ads)
20163 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20164 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20165 @cindex Stream operations
20166 @cindex String stream operations
20167
20168 @noindent
20169 This package provides a set of stream subprograms for standard string types.
20170 It is intended primarily to support implicit use of such subprograms when
20171 stream attributes are applied to string types, but the subprograms in this
20172 package can be used directly by application programs.
20173
20174 @node System.Unsigned_Types (s-unstyp.ads)
20175 @section @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20176 @cindex @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20177
20178 @noindent
20179 This package contains definitions of standard unsigned types that
20180 correspond in size to the standard signed types declared in Standard,
20181 and (unlike the types in Interfaces) have corresponding names. It
20182 also contains some related definitions for other specialized types
20183 used by the compiler in connection with packed array types.
20184
20185 @node System.Wch_Cnv (s-wchcnv.ads)
20186 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20187 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20188 @cindex Wide Character, Representation
20189 @cindex Wide String, Conversion
20190 @cindex Representation of wide characters
20191
20192 @noindent
20193 This package provides routines for converting between
20194 wide and wide wide characters and a representation as a value of type
20195 @code{Standard.String}, using a specified wide character
20196 encoding method. It uses definitions in
20197 package @code{System.Wch_Con}.
20198
20199 @node System.Wch_Con (s-wchcon.ads)
20200 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
20201 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
20202
20203 @noindent
20204 This package provides definitions and descriptions of
20205 the various methods used for encoding wide characters
20206 in ordinary strings. These definitions are used by
20207 the package @code{System.Wch_Cnv}.
20208
20209 @node Interfacing to Other Languages
20210 @chapter Interfacing to Other Languages
20211 @noindent
20212 The facilities in annex B of the Ada Reference Manual are fully
20213 implemented in GNAT, and in addition, a full interface to C++ is
20214 provided.
20215
20216 @menu
20217 * Interfacing to C::
20218 * Interfacing to C++::
20219 * Interfacing to COBOL::
20220 * Interfacing to Fortran::
20221 * Interfacing to non-GNAT Ada code::
20222 @end menu
20223
20224 @node Interfacing to C
20225 @section Interfacing to C
20226
20227 @noindent
20228 Interfacing to C with GNAT can use one of two approaches:
20229
20230 @itemize @bullet
20231 @item
20232 The types in the package @code{Interfaces.C} may be used.
20233 @item
20234 Standard Ada types may be used directly. This may be less portable to
20235 other compilers, but will work on all GNAT compilers, which guarantee
20236 correspondence between the C and Ada types.
20237 @end itemize
20238
20239 @noindent
20240 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
20241 effect, since this is the default. The following table shows the
20242 correspondence between Ada scalar types and the corresponding C types.
20243
20244 @table @code
20245 @item Integer
20246 @code{int}
20247 @item Short_Integer
20248 @code{short}
20249 @item Short_Short_Integer
20250 @code{signed char}
20251 @item Long_Integer
20252 @code{long}
20253 @item Long_Long_Integer
20254 @code{long long}
20255 @item Short_Float
20256 @code{float}
20257 @item Float
20258 @code{float}
20259 @item Long_Float
20260 @code{double}
20261 @item Long_Long_Float
20262 This is the longest floating-point type supported by the hardware.
20263 @end table
20264
20265 @noindent
20266 Additionally, there are the following general correspondences between Ada
20267 and C types:
20268 @itemize @bullet
20269 @item
20270 Ada enumeration types map to C enumeration types directly if pragma
20271 @code{Convention C} is specified, which causes them to have int
20272 length. Without pragma @code{Convention C}, Ada enumeration types map to
20273 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
20274 @code{int}, respectively) depending on the number of values passed.
20275 This is the only case in which pragma @code{Convention C} affects the
20276 representation of an Ada type.
20277
20278 @item
20279 Ada access types map to C pointers, except for the case of pointers to
20280 unconstrained types in Ada, which have no direct C equivalent.
20281
20282 @item
20283 Ada arrays map directly to C arrays.
20284
20285 @item
20286 Ada records map directly to C structures.
20287
20288 @item
20289 Packed Ada records map to C structures where all members are bit fields
20290 of the length corresponding to the @code{@var{type}'Size} value in Ada.
20291 @end itemize
20292
20293 @node Interfacing to C++
20294 @section Interfacing to C++
20295
20296 @noindent
20297 The interface to C++ makes use of the following pragmas, which are
20298 primarily intended to be constructed automatically using a binding generator
20299 tool, although it is possible to construct them by hand.
20300
20301 Using these pragmas it is possible to achieve complete
20302 inter-operability between Ada tagged types and C++ class definitions.
20303 See @ref{Implementation Defined Pragmas}, for more details.
20304
20305 @table @code
20306 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
20307 The argument denotes an entity in the current declarative region that is
20308 declared as a tagged or untagged record type. It indicates that the type
20309 corresponds to an externally declared C++ class type, and is to be laid
20310 out the same way that C++ would lay out the type.
20311
20312 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
20313 for backward compatibility but its functionality is available
20314 using pragma @code{Import} with @code{Convention} = @code{CPP}.
20315
20316 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
20317 This pragma identifies an imported function (imported in the usual way
20318 with pragma @code{Import}) as corresponding to a C++ constructor.
20319 @end table
20320
20321 A few restrictions are placed on the use of the @code{Access} attribute
20322 in conjunction with subprograms subject to convention @code{CPP}: the
20323 attribute may be used neither on primitive operations of a tagged
20324 record type with convention @code{CPP}, imported or not, nor on
20325 subprograms imported with pragma @code{CPP_Constructor}.
20326
20327 In addition, C++ exceptions are propagated and can be handled in an
20328 @code{others} choice of an exception handler. The corresponding Ada
20329 occurrence has no message, and the simple name of the exception identity
20330 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
20331 tasks works properly when such foreign exceptions are propagated.
20332
20333 It is also possible to import a C++ exception using the following syntax:
20334
20335 @smallexample @c ada
20336 LOCAL_NAME : exception;
20337 pragma Import (Cpp,
20338 [Entity =>] LOCAL_NAME,
20339 [External_Name =>] static_string_EXPRESSION);
20340 @end smallexample
20341
20342 @noindent
20343 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
20344 cover a specific C++ exception in an exception handler.
20345
20346 @node Interfacing to COBOL
20347 @section Interfacing to COBOL
20348
20349 @noindent
20350 Interfacing to COBOL is achieved as described in section B.4 of
20351 the Ada Reference Manual.
20352
20353 @node Interfacing to Fortran
20354 @section Interfacing to Fortran
20355
20356 @noindent
20357 Interfacing to Fortran is achieved as described in section B.5 of the
20358 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
20359 multi-dimensional array causes the array to be stored in column-major
20360 order as required for convenient interface to Fortran.
20361
20362 @node Interfacing to non-GNAT Ada code
20363 @section Interfacing to non-GNAT Ada code
20364
20365 It is possible to specify the convention @code{Ada} in a pragma
20366 @code{Import} or pragma @code{Export}. However this refers to
20367 the calling conventions used by GNAT, which may or may not be
20368 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
20369 compiler to allow interoperation.
20370
20371 If arguments types are kept simple, and if the foreign compiler generally
20372 follows system calling conventions, then it may be possible to integrate
20373 files compiled by other Ada compilers, provided that the elaboration
20374 issues are adequately addressed (for example by eliminating the
20375 need for any load time elaboration).
20376
20377 In particular, GNAT running on VMS is designed to
20378 be highly compatible with the DEC Ada 83 compiler, so this is one
20379 case in which it is possible to import foreign units of this type,
20380 provided that the data items passed are restricted to simple scalar
20381 values or simple record types without variants, or simple array
20382 types with fixed bounds.
20383
20384 @node Specialized Needs Annexes
20385 @chapter Specialized Needs Annexes
20386
20387 @noindent
20388 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
20389 required in all implementations. However, as described in this chapter,
20390 GNAT implements all of these annexes:
20391
20392 @table @asis
20393 @item Systems Programming (Annex C)
20394 The Systems Programming Annex is fully implemented.
20395
20396 @item Real-Time Systems (Annex D)
20397 The Real-Time Systems Annex is fully implemented.
20398
20399 @item Distributed Systems (Annex E)
20400 Stub generation is fully implemented in the GNAT compiler. In addition,
20401 a complete compatible PCS is available as part of the GLADE system,
20402 a separate product. When the two
20403 products are used in conjunction, this annex is fully implemented.
20404
20405 @item Information Systems (Annex F)
20406 The Information Systems annex is fully implemented.
20407
20408 @item Numerics (Annex G)
20409 The Numerics Annex is fully implemented.
20410
20411 @item Safety and Security / High-Integrity Systems (Annex H)
20412 The Safety and Security Annex (termed the High-Integrity Systems Annex
20413 in Ada 2005) is fully implemented.
20414 @end table
20415
20416 @node Implementation of Specific Ada Features
20417 @chapter Implementation of Specific Ada Features
20418
20419 @noindent
20420 This chapter describes the GNAT implementation of several Ada language
20421 facilities.
20422
20423 @menu
20424 * Machine Code Insertions::
20425 * GNAT Implementation of Tasking::
20426 * GNAT Implementation of Shared Passive Packages::
20427 * Code Generation for Array Aggregates::
20428 * The Size of Discriminated Records with Default Discriminants::
20429 * Strict Conformance to the Ada Reference Manual::
20430 @end menu
20431
20432 @node Machine Code Insertions
20433 @section Machine Code Insertions
20434 @cindex Machine Code insertions
20435
20436 @noindent
20437 Package @code{Machine_Code} provides machine code support as described
20438 in the Ada Reference Manual in two separate forms:
20439 @itemize @bullet
20440 @item
20441 Machine code statements, consisting of qualified expressions that
20442 fit the requirements of RM section 13.8.
20443 @item
20444 An intrinsic callable procedure, providing an alternative mechanism of
20445 including machine instructions in a subprogram.
20446 @end itemize
20447
20448 @noindent
20449 The two features are similar, and both are closely related to the mechanism
20450 provided by the asm instruction in the GNU C compiler. Full understanding
20451 and use of the facilities in this package requires understanding the asm
20452 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
20453 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
20454
20455 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
20456 semantic restrictions and effects as described below. Both are provided so
20457 that the procedure call can be used as a statement, and the function call
20458 can be used to form a code_statement.
20459
20460 The first example given in the GCC documentation is the C @code{asm}
20461 instruction:
20462 @smallexample
20463 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
20464 @end smallexample
20465
20466 @noindent
20467 The equivalent can be written for GNAT as:
20468
20469 @smallexample @c ada
20470 Asm ("fsinx %1 %0",
20471 My_Float'Asm_Output ("=f", result),
20472 My_Float'Asm_Input ("f", angle));
20473 @end smallexample
20474
20475 @noindent
20476 The first argument to @code{Asm} is the assembler template, and is
20477 identical to what is used in GNU C@. This string must be a static
20478 expression. The second argument is the output operand list. It is
20479 either a single @code{Asm_Output} attribute reference, or a list of such
20480 references enclosed in parentheses (technically an array aggregate of
20481 such references).
20482
20483 The @code{Asm_Output} attribute denotes a function that takes two
20484 parameters. The first is a string, the second is the name of a variable
20485 of the type designated by the attribute prefix. The first (string)
20486 argument is required to be a static expression and designates the
20487 constraint for the parameter (e.g.@: what kind of register is
20488 required). The second argument is the variable to be updated with the
20489 result. The possible values for constraint are the same as those used in
20490 the RTL, and are dependent on the configuration file used to build the
20491 GCC back end. If there are no output operands, then this argument may
20492 either be omitted, or explicitly given as @code{No_Output_Operands}.
20493
20494 The second argument of @code{@var{my_float}'Asm_Output} functions as
20495 though it were an @code{out} parameter, which is a little curious, but
20496 all names have the form of expressions, so there is no syntactic
20497 irregularity, even though normally functions would not be permitted
20498 @code{out} parameters. The third argument is the list of input
20499 operands. It is either a single @code{Asm_Input} attribute reference, or
20500 a list of such references enclosed in parentheses (technically an array
20501 aggregate of such references).
20502
20503 The @code{Asm_Input} attribute denotes a function that takes two
20504 parameters. The first is a string, the second is an expression of the
20505 type designated by the prefix. The first (string) argument is required
20506 to be a static expression, and is the constraint for the parameter,
20507 (e.g.@: what kind of register is required). The second argument is the
20508 value to be used as the input argument. The possible values for the
20509 constant are the same as those used in the RTL, and are dependent on
20510 the configuration file used to built the GCC back end.
20511
20512 If there are no input operands, this argument may either be omitted, or
20513 explicitly given as @code{No_Input_Operands}. The fourth argument, not
20514 present in the above example, is a list of register names, called the
20515 @dfn{clobber} argument. This argument, if given, must be a static string
20516 expression, and is a space or comma separated list of names of registers
20517 that must be considered destroyed as a result of the @code{Asm} call. If
20518 this argument is the null string (the default value), then the code
20519 generator assumes that no additional registers are destroyed.
20520
20521 The fifth argument, not present in the above example, called the
20522 @dfn{volatile} argument, is by default @code{False}. It can be set to
20523 the literal value @code{True} to indicate to the code generator that all
20524 optimizations with respect to the instruction specified should be
20525 suppressed, and that in particular, for an instruction that has outputs,
20526 the instruction will still be generated, even if none of the outputs are
20527 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
20528 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
20529 Generally it is strongly advisable to use Volatile for any ASM statement
20530 that is missing either input or output operands, or when two or more ASM
20531 statements appear in sequence, to avoid unwanted optimizations. A warning
20532 is generated if this advice is not followed.
20533
20534 The @code{Asm} subprograms may be used in two ways. First the procedure
20535 forms can be used anywhere a procedure call would be valid, and
20536 correspond to what the RM calls ``intrinsic'' routines. Such calls can
20537 be used to intersperse machine instructions with other Ada statements.
20538 Second, the function forms, which return a dummy value of the limited
20539 private type @code{Asm_Insn}, can be used in code statements, and indeed
20540 this is the only context where such calls are allowed. Code statements
20541 appear as aggregates of the form:
20542
20543 @smallexample @c ada
20544 Asm_Insn'(Asm (@dots{}));
20545 Asm_Insn'(Asm_Volatile (@dots{}));
20546 @end smallexample
20547
20548 @noindent
20549 In accordance with RM rules, such code statements are allowed only
20550 within subprograms whose entire body consists of such statements. It is
20551 not permissible to intermix such statements with other Ada statements.
20552
20553 Typically the form using intrinsic procedure calls is more convenient
20554 and more flexible. The code statement form is provided to meet the RM
20555 suggestion that such a facility should be made available. The following
20556 is the exact syntax of the call to @code{Asm}. As usual, if named notation
20557 is used, the arguments may be given in arbitrary order, following the
20558 normal rules for use of positional and named arguments)
20559
20560 @smallexample
20561 ASM_CALL ::= Asm (
20562 [Template =>] static_string_EXPRESSION
20563 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
20564 [,[Inputs =>] INPUT_OPERAND_LIST ]
20565 [,[Clobber =>] static_string_EXPRESSION ]
20566 [,[Volatile =>] static_boolean_EXPRESSION] )
20567
20568 OUTPUT_OPERAND_LIST ::=
20569 [PREFIX.]No_Output_Operands
20570 | OUTPUT_OPERAND_ATTRIBUTE
20571 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
20572
20573 OUTPUT_OPERAND_ATTRIBUTE ::=
20574 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
20575
20576 INPUT_OPERAND_LIST ::=
20577 [PREFIX.]No_Input_Operands
20578 | INPUT_OPERAND_ATTRIBUTE
20579 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
20580
20581 INPUT_OPERAND_ATTRIBUTE ::=
20582 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
20583 @end smallexample
20584
20585 @noindent
20586 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
20587 are declared in the package @code{Machine_Code} and must be referenced
20588 according to normal visibility rules. In particular if there is no
20589 @code{use} clause for this package, then appropriate package name
20590 qualification is required.
20591
20592 @node GNAT Implementation of Tasking
20593 @section GNAT Implementation of Tasking
20594
20595 @noindent
20596 This chapter outlines the basic GNAT approach to tasking (in particular,
20597 a multi-layered library for portability) and discusses issues related
20598 to compliance with the Real-Time Systems Annex.
20599
20600 @menu
20601 * Mapping Ada Tasks onto the Underlying Kernel Threads::
20602 * Ensuring Compliance with the Real-Time Annex::
20603 @end menu
20604
20605 @node Mapping Ada Tasks onto the Underlying Kernel Threads
20606 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
20607
20608 @noindent
20609 GNAT's run-time support comprises two layers:
20610
20611 @itemize @bullet
20612 @item GNARL (GNAT Run-time Layer)
20613 @item GNULL (GNAT Low-level Library)
20614 @end itemize
20615
20616 @noindent
20617 In GNAT, Ada's tasking services rely on a platform and OS independent
20618 layer known as GNARL@. This code is responsible for implementing the
20619 correct semantics of Ada's task creation, rendezvous, protected
20620 operations etc.
20621
20622 GNARL decomposes Ada's tasking semantics into simpler lower level
20623 operations such as create a thread, set the priority of a thread,
20624 yield, create a lock, lock/unlock, etc. The spec for these low-level
20625 operations constitutes GNULLI, the GNULL Interface. This interface is
20626 directly inspired from the POSIX real-time API@.
20627
20628 If the underlying executive or OS implements the POSIX standard
20629 faithfully, the GNULL Interface maps as is to the services offered by
20630 the underlying kernel. Otherwise, some target dependent glue code maps
20631 the services offered by the underlying kernel to the semantics expected
20632 by GNARL@.
20633
20634 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
20635 key point is that each Ada task is mapped on a thread in the underlying
20636 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
20637
20638 In addition Ada task priorities map onto the underlying thread priorities.
20639 Mapping Ada tasks onto the underlying kernel threads has several advantages:
20640
20641 @itemize @bullet
20642 @item
20643 The underlying scheduler is used to schedule the Ada tasks. This
20644 makes Ada tasks as efficient as kernel threads from a scheduling
20645 standpoint.
20646
20647 @item
20648 Interaction with code written in C containing threads is eased
20649 since at the lowest level Ada tasks and C threads map onto the same
20650 underlying kernel concept.
20651
20652 @item
20653 When an Ada task is blocked during I/O the remaining Ada tasks are
20654 able to proceed.
20655
20656 @item
20657 On multiprocessor systems Ada tasks can execute in parallel.
20658 @end itemize
20659
20660 @noindent
20661 Some threads libraries offer a mechanism to fork a new process, with the
20662 child process duplicating the threads from the parent.
20663 GNAT does not
20664 support this functionality when the parent contains more than one task.
20665 @cindex Forking a new process
20666
20667 @node Ensuring Compliance with the Real-Time Annex
20668 @subsection Ensuring Compliance with the Real-Time Annex
20669 @cindex Real-Time Systems Annex compliance
20670
20671 @noindent
20672 Although mapping Ada tasks onto
20673 the underlying threads has significant advantages, it does create some
20674 complications when it comes to respecting the scheduling semantics
20675 specified in the real-time annex (Annex D).
20676
20677 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
20678 scheduling policy states:
20679
20680 @quotation
20681 @emph{When the active priority of a ready task that is not running
20682 changes, or the setting of its base priority takes effect, the
20683 task is removed from the ready queue for its old active priority
20684 and is added at the tail of the ready queue for its new active
20685 priority, except in the case where the active priority is lowered
20686 due to the loss of inherited priority, in which case the task is
20687 added at the head of the ready queue for its new active priority.}
20688 @end quotation
20689
20690 @noindent
20691 While most kernels do put tasks at the end of the priority queue when
20692 a task changes its priority, (which respects the main
20693 FIFO_Within_Priorities requirement), almost none keep a thread at the
20694 beginning of its priority queue when its priority drops from the loss
20695 of inherited priority.
20696
20697 As a result most vendors have provided incomplete Annex D implementations.
20698
20699 The GNAT run-time, has a nice cooperative solution to this problem
20700 which ensures that accurate FIFO_Within_Priorities semantics are
20701 respected.
20702
20703 The principle is as follows. When an Ada task T is about to start
20704 running, it checks whether some other Ada task R with the same
20705 priority as T has been suspended due to the loss of priority
20706 inheritance. If this is the case, T yields and is placed at the end of
20707 its priority queue. When R arrives at the front of the queue it
20708 executes.
20709
20710 Note that this simple scheme preserves the relative order of the tasks
20711 that were ready to execute in the priority queue where R has been
20712 placed at the end.
20713
20714 @node GNAT Implementation of Shared Passive Packages
20715 @section GNAT Implementation of Shared Passive Packages
20716 @cindex Shared passive packages
20717
20718 @noindent
20719 GNAT fully implements the pragma @code{Shared_Passive} for
20720 @cindex pragma @code{Shared_Passive}
20721 the purpose of designating shared passive packages.
20722 This allows the use of passive partitions in the
20723 context described in the Ada Reference Manual; i.e., for communication
20724 between separate partitions of a distributed application using the
20725 features in Annex E.
20726 @cindex Annex E
20727 @cindex Distribution Systems Annex
20728
20729 However, the implementation approach used by GNAT provides for more
20730 extensive usage as follows:
20731
20732 @table @emph
20733 @item Communication between separate programs
20734
20735 This allows separate programs to access the data in passive
20736 partitions, using protected objects for synchronization where
20737 needed. The only requirement is that the two programs have a
20738 common shared file system. It is even possible for programs
20739 running on different machines with different architectures
20740 (e.g.@: different endianness) to communicate via the data in
20741 a passive partition.
20742
20743 @item Persistence between program runs
20744
20745 The data in a passive package can persist from one run of a
20746 program to another, so that a later program sees the final
20747 values stored by a previous run of the same program.
20748
20749 @end table
20750
20751 @noindent
20752 The implementation approach used is to store the data in files. A
20753 separate stream file is created for each object in the package, and
20754 an access to an object causes the corresponding file to be read or
20755 written.
20756
20757 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
20758 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
20759 set to the directory to be used for these files.
20760 The files in this directory
20761 have names that correspond to their fully qualified names. For
20762 example, if we have the package
20763
20764 @smallexample @c ada
20765 package X is
20766 pragma Shared_Passive (X);
20767 Y : Integer;
20768 Z : Float;
20769 end X;
20770 @end smallexample
20771
20772 @noindent
20773 and the environment variable is set to @code{/stemp/}, then the files created
20774 will have the names:
20775
20776 @smallexample
20777 /stemp/x.y
20778 /stemp/x.z
20779 @end smallexample
20780
20781 @noindent
20782 These files are created when a value is initially written to the object, and
20783 the files are retained until manually deleted. This provides the persistence
20784 semantics. If no file exists, it means that no partition has assigned a value
20785 to the variable; in this case the initial value declared in the package
20786 will be used. This model ensures that there are no issues in synchronizing
20787 the elaboration process, since elaboration of passive packages elaborates the
20788 initial values, but does not create the files.
20789
20790 The files are written using normal @code{Stream_IO} access.
20791 If you want to be able
20792 to communicate between programs or partitions running on different
20793 architectures, then you should use the XDR versions of the stream attribute
20794 routines, since these are architecture independent.
20795
20796 If active synchronization is required for access to the variables in the
20797 shared passive package, then as described in the Ada Reference Manual, the
20798 package may contain protected objects used for this purpose. In this case
20799 a lock file (whose name is @file{___lock} (three underscores)
20800 is created in the shared memory directory.
20801 @cindex @file{___lock} file (for shared passive packages)
20802 This is used to provide the required locking
20803 semantics for proper protected object synchronization.
20804
20805 As of January 2003, GNAT supports shared passive packages on all platforms
20806 except for OpenVMS.
20807
20808 @node Code Generation for Array Aggregates
20809 @section Code Generation for Array Aggregates
20810
20811 @menu
20812 * Static constant aggregates with static bounds::
20813 * Constant aggregates with unconstrained nominal types::
20814 * Aggregates with static bounds::
20815 * Aggregates with non-static bounds::
20816 * Aggregates in assignment statements::
20817 @end menu
20818
20819 @noindent
20820 Aggregates have a rich syntax and allow the user to specify the values of
20821 complex data structures by means of a single construct. As a result, the
20822 code generated for aggregates can be quite complex and involve loops, case
20823 statements and multiple assignments. In the simplest cases, however, the
20824 compiler will recognize aggregates whose components and constraints are
20825 fully static, and in those cases the compiler will generate little or no
20826 executable code. The following is an outline of the code that GNAT generates
20827 for various aggregate constructs. For further details, you will find it
20828 useful to examine the output produced by the -gnatG flag to see the expanded
20829 source that is input to the code generator. You may also want to examine
20830 the assembly code generated at various levels of optimization.
20831
20832 The code generated for aggregates depends on the context, the component values,
20833 and the type. In the context of an object declaration the code generated is
20834 generally simpler than in the case of an assignment. As a general rule, static
20835 component values and static subtypes also lead to simpler code.
20836
20837 @node Static constant aggregates with static bounds
20838 @subsection Static constant aggregates with static bounds
20839
20840 @noindent
20841 For the declarations:
20842 @smallexample @c ada
20843 type One_Dim is array (1..10) of integer;
20844 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
20845 @end smallexample
20846
20847 @noindent
20848 GNAT generates no executable code: the constant ar0 is placed in static memory.
20849 The same is true for constant aggregates with named associations:
20850
20851 @smallexample @c ada
20852 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
20853 Cr3 : constant One_Dim := (others => 7777);
20854 @end smallexample
20855
20856 @noindent
20857 The same is true for multidimensional constant arrays such as:
20858
20859 @smallexample @c ada
20860 type two_dim is array (1..3, 1..3) of integer;
20861 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
20862 @end smallexample
20863
20864 @noindent
20865 The same is true for arrays of one-dimensional arrays: the following are
20866 static:
20867
20868 @smallexample @c ada
20869 type ar1b is array (1..3) of boolean;
20870 type ar_ar is array (1..3) of ar1b;
20871 None : constant ar1b := (others => false); -- fully static
20872 None2 : constant ar_ar := (1..3 => None); -- fully static
20873 @end smallexample
20874
20875 @noindent
20876 However, for multidimensional aggregates with named associations, GNAT will
20877 generate assignments and loops, even if all associations are static. The
20878 following two declarations generate a loop for the first dimension, and
20879 individual component assignments for the second dimension:
20880
20881 @smallexample @c ada
20882 Zero1: constant two_dim := (1..3 => (1..3 => 0));
20883 Zero2: constant two_dim := (others => (others => 0));
20884 @end smallexample
20885
20886 @node Constant aggregates with unconstrained nominal types
20887 @subsection Constant aggregates with unconstrained nominal types
20888
20889 @noindent
20890 In such cases the aggregate itself establishes the subtype, so that
20891 associations with @code{others} cannot be used. GNAT determines the
20892 bounds for the actual subtype of the aggregate, and allocates the
20893 aggregate statically as well. No code is generated for the following:
20894
20895 @smallexample @c ada
20896 type One_Unc is array (natural range <>) of integer;
20897 Cr_Unc : constant One_Unc := (12,24,36);
20898 @end smallexample
20899
20900 @node Aggregates with static bounds
20901 @subsection Aggregates with static bounds
20902
20903 @noindent
20904 In all previous examples the aggregate was the initial (and immutable) value
20905 of a constant. If the aggregate initializes a variable, then code is generated
20906 for it as a combination of individual assignments and loops over the target
20907 object. The declarations
20908
20909 @smallexample @c ada
20910 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
20911 Cr_Var2 : One_Dim := (others > -1);
20912 @end smallexample
20913
20914 @noindent
20915 generate the equivalent of
20916
20917 @smallexample @c ada
20918 Cr_Var1 (1) := 2;
20919 Cr_Var1 (2) := 3;
20920 Cr_Var1 (3) := 5;
20921 Cr_Var1 (4) := 11;
20922
20923 for I in Cr_Var2'range loop
20924 Cr_Var2 (I) := -1;
20925 end loop;
20926 @end smallexample
20927
20928 @node Aggregates with non-static bounds
20929 @subsection Aggregates with non-static bounds
20930
20931 @noindent
20932 If the bounds of the aggregate are not statically compatible with the bounds
20933 of the nominal subtype of the target, then constraint checks have to be
20934 generated on the bounds. For a multidimensional array, constraint checks may
20935 have to be applied to sub-arrays individually, if they do not have statically
20936 compatible subtypes.
20937
20938 @node Aggregates in assignment statements
20939 @subsection Aggregates in assignment statements
20940
20941 @noindent
20942 In general, aggregate assignment requires the construction of a temporary,
20943 and a copy from the temporary to the target of the assignment. This is because
20944 it is not always possible to convert the assignment into a series of individual
20945 component assignments. For example, consider the simple case:
20946
20947 @smallexample @c ada
20948 A := (A(2), A(1));
20949 @end smallexample
20950
20951 @noindent
20952 This cannot be converted into:
20953
20954 @smallexample @c ada
20955 A(1) := A(2);
20956 A(2) := A(1);
20957 @end smallexample
20958
20959 @noindent
20960 So the aggregate has to be built first in a separate location, and then
20961 copied into the target. GNAT recognizes simple cases where this intermediate
20962 step is not required, and the assignments can be performed in place, directly
20963 into the target. The following sufficient criteria are applied:
20964
20965 @itemize @bullet
20966 @item
20967 The bounds of the aggregate are static, and the associations are static.
20968 @item
20969 The components of the aggregate are static constants, names of
20970 simple variables that are not renamings, or expressions not involving
20971 indexed components whose operands obey these rules.
20972 @end itemize
20973
20974 @noindent
20975 If any of these conditions are violated, the aggregate will be built in
20976 a temporary (created either by the front-end or the code generator) and then
20977 that temporary will be copied onto the target.
20978
20979 @node The Size of Discriminated Records with Default Discriminants
20980 @section The Size of Discriminated Records with Default Discriminants
20981
20982 @noindent
20983 If a discriminated type @code{T} has discriminants with default values, it is
20984 possible to declare an object of this type without providing an explicit
20985 constraint:
20986
20987 @smallexample @c ada
20988 @group
20989 type Size is range 1..100;
20990
20991 type Rec (D : Size := 15) is record
20992 Name : String (1..D);
20993 end T;
20994
20995 Word : Rec;
20996 @end group
20997 @end smallexample
20998
20999 @noindent
21000 Such an object is said to be @emph{unconstrained}.
21001 The discriminant of the object
21002 can be modified by a full assignment to the object, as long as it preserves the
21003 relation between the value of the discriminant, and the value of the components
21004 that depend on it:
21005
21006 @smallexample @c ada
21007 @group
21008 Word := (3, "yes");
21009
21010 Word := (5, "maybe");
21011
21012 Word := (5, "no"); -- raises Constraint_Error
21013 @end group
21014 @end smallexample
21015
21016 @noindent
21017 In order to support this behavior efficiently, an unconstrained object is
21018 given the maximum size that any value of the type requires. In the case
21019 above, @code{Word} has storage for the discriminant and for
21020 a @code{String} of length 100.
21021 It is important to note that unconstrained objects do not require dynamic
21022 allocation. It would be an improper implementation to place on the heap those
21023 components whose size depends on discriminants. (This improper implementation
21024 was used by some Ada83 compilers, where the @code{Name} component above
21025 would have
21026 been stored as a pointer to a dynamic string). Following the principle that
21027 dynamic storage management should never be introduced implicitly,
21028 an Ada compiler should reserve the full size for an unconstrained declared
21029 object, and place it on the stack.
21030
21031 This maximum size approach
21032 has been a source of surprise to some users, who expect the default
21033 values of the discriminants to determine the size reserved for an
21034 unconstrained object: ``If the default is 15, why should the object occupy
21035 a larger size?''
21036 The answer, of course, is that the discriminant may be later modified,
21037 and its full range of values must be taken into account. This is why the
21038 declaration:
21039
21040 @smallexample
21041 @group
21042 type Rec (D : Positive := 15) is record
21043 Name : String (1..D);
21044 end record;
21045
21046 Too_Large : Rec;
21047 @end group
21048 @end smallexample
21049
21050 @noindent
21051 is flagged by the compiler with a warning:
21052 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
21053 because the required size includes @code{Positive'Last}
21054 bytes. As the first example indicates, the proper approach is to declare an
21055 index type of ``reasonable'' range so that unconstrained objects are not too
21056 large.
21057
21058 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
21059 created in the heap by means of an allocator, then it is @emph{not}
21060 unconstrained:
21061 it is constrained by the default values of the discriminants, and those values
21062 cannot be modified by full assignment. This is because in the presence of
21063 aliasing all views of the object (which may be manipulated by different tasks,
21064 say) must be consistent, so it is imperative that the object, once created,
21065 remain invariant.
21066
21067 @node Strict Conformance to the Ada Reference Manual
21068 @section Strict Conformance to the Ada Reference Manual
21069
21070 @noindent
21071 The dynamic semantics defined by the Ada Reference Manual impose a set of
21072 run-time checks to be generated. By default, the GNAT compiler will insert many
21073 run-time checks into the compiled code, including most of those required by the
21074 Ada Reference Manual. However, there are three checks that are not enabled
21075 in the default mode for efficiency reasons: arithmetic overflow checking for
21076 integer operations (including division by zero), checks for access before
21077 elaboration on subprogram calls, and stack overflow checking (most operating
21078 systems do not perform this check by default).
21079
21080 Strict conformance to the Ada Reference Manual can be achieved by adding
21081 three compiler options for overflow checking for integer operations
21082 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
21083 calls and generic instantiations (@option{-gnatE}), and stack overflow
21084 checking (@option{-fstack-check}).
21085
21086 Note that the result of a floating point arithmetic operation in overflow and
21087 invalid situations, when the @code{Machine_Overflows} attribute of the result
21088 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
21089 case for machines compliant with the IEEE floating-point standard, but on
21090 machines that are not fully compliant with this standard, such as Alpha, the
21091 @option{-mieee} compiler flag must be used for achieving IEEE confirming
21092 behavior (although at the cost of a significant performance penalty), so
21093 infinite and NaN values are properly generated.
21094
21095
21096 @node Implementation of Ada 2012 Features
21097 @chapter Implementation of Ada 2012 Features
21098 @cindex Ada 2012 implementation status
21099
21100 This chapter contains a complete list of Ada 2012 features that have been
21101 implemented as of GNAT version 6.4. Generally, these features are only
21102 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
21103 @cindex @option{-gnat12} option
21104 or if the configuration pragma @code{Ada_2012} is used.
21105 @cindex pragma @code{Ada_2012}
21106 @cindex configuration pragma @code{Ada_2012}
21107 @cindex @code{Ada_2012} configuration pragma
21108 However, new pragmas, attributes, and restrictions are
21109 unconditionally available, since the Ada 95 standard allows the addition of
21110 new pragmas, attributes, and restrictions (there are exceptions, which are
21111 documented in the individual descriptions), and also certain packages
21112 were made available in earlier versions of Ada.
21113
21114 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
21115 This date shows the implementation date of the feature. Any wavefront
21116 subsequent to this date will contain the indicated feature, as will any
21117 subsequent releases. A date of 0000-00-00 means that GNAT has always
21118 implemented the feature, or implemented it as soon as it appeared as a
21119 binding interpretation.
21120
21121 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
21122 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
21123 The features are ordered based on the relevant sections of the Ada
21124 Reference Manual (``RM''). When a given AI relates to multiple points
21125 in the RM, the earliest is used.
21126
21127 A complete description of the AIs may be found in
21128 @url{www.ada-auth.org/ai05-summary.html}.
21129
21130 @itemize @bullet
21131
21132 @item
21133 @emph{AI-0176 Quantified expressions (2010-09-29)}
21134 @cindex AI-0176 (Ada 2012 feature)
21135
21136 @noindent
21137 Both universally and existentially quantified expressions are implemented.
21138 They use the new syntax for iterators proposed in AI05-139-2, as well as
21139 the standard Ada loop syntax.
21140
21141 @noindent
21142 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
21143
21144 @item
21145 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
21146 @cindex AI-0079 (Ada 2012 feature)
21147
21148 @noindent
21149 Wide characters in the unicode category @i{other_format} are now allowed in
21150 source programs between tokens, but not within a token such as an identifier.
21151
21152 @noindent
21153 RM References: 2.01 (4/2) 2.02 (7)
21154
21155 @item
21156 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
21157 @cindex AI-0091 (Ada 2012 feature)
21158
21159 @noindent
21160 Wide characters in the unicode category @i{other_format} are not permitted
21161 within an identifier, since this can be a security problem. The error
21162 message for this case has been improved to be more specific, but GNAT has
21163 never allowed such characters to appear in identifiers.
21164
21165 @noindent
21166 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)
21167
21168 @item
21169 @emph{AI-0100 Placement of pragmas (2010-07-01)}
21170 @cindex AI-0100 (Ada 2012 feature)
21171
21172 @noindent
21173 This AI is an earlier version of AI-163. It simplifies the rules
21174 for legal placement of pragmas. In the case of lists that allow pragmas, if
21175 the list may have no elements, then the list may consist solely of pragmas.
21176
21177 @noindent
21178 RM References: 2.08 (7)
21179
21180 @item
21181 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
21182 @cindex AI-0163 (Ada 2012 feature)
21183
21184 @noindent
21185 A statement sequence may be composed entirely of pragmas. It is no longer
21186 necessary to add a dummy @code{null} statement to make the sequence legal.
21187
21188 @noindent
21189 RM References: 2.08 (7) 2.08 (16)
21190
21191
21192 @item
21193 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
21194 @cindex AI-0080 (Ada 2012 feature)
21195
21196 @noindent
21197 This is an editorial change only, described as non-testable in the AI.
21198
21199 @noindent
21200 RM References: 3.01 (7)
21201
21202
21203 @item
21204 @emph{AI-0183 Aspect specifications (2010-08-16)}
21205 @cindex AI-0183 (Ada 2012 feature)
21206
21207 @noindent
21208 Aspect specifications have been fully implemented except for pre and post-
21209 conditions, and type invariants, which have their own separate AI's. All
21210 forms of declarations listed in the AI are supported. The following is a
21211 list of the aspects supported (with GNAT implementation aspects marked)
21212
21213 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
21214 @item @code{Ada_2005} @tab -- GNAT
21215 @item @code{Ada_2012} @tab -- GNAT
21216 @item @code{Address} @tab
21217 @item @code{Alignment} @tab
21218 @item @code{Atomic} @tab
21219 @item @code{Atomic_Components} @tab
21220 @item @code{Bit_Order} @tab
21221 @item @code{Component_Size} @tab
21222 @item @code{Contract_Cases} @tab -- GNAT
21223 @item @code{Discard_Names} @tab
21224 @item @code{External_Tag} @tab
21225 @item @code{Favor_Top_Level} @tab -- GNAT
21226 @item @code{Inline} @tab
21227 @item @code{Inline_Always} @tab -- GNAT
21228 @item @code{Invariant} @tab -- GNAT
21229 @item @code{Machine_Radix} @tab
21230 @item @code{No_Return} @tab
21231 @item @code{Object_Size} @tab -- GNAT
21232 @item @code{Pack} @tab
21233 @item @code{Persistent_BSS} @tab -- GNAT
21234 @item @code{Post} @tab
21235 @item @code{Pre} @tab
21236 @item @code{Predicate} @tab
21237 @item @code{Preelaborable_Initialization} @tab
21238 @item @code{Pure_Function} @tab -- GNAT
21239 @item @code{Remote_Access_Type} @tab -- GNAT
21240 @item @code{Shared} @tab -- GNAT
21241 @item @code{Size} @tab
21242 @item @code{Storage_Pool} @tab
21243 @item @code{Storage_Size} @tab
21244 @item @code{Stream_Size} @tab
21245 @item @code{Suppress} @tab
21246 @item @code{Suppress_Debug_Info} @tab -- GNAT
21247 @item @code{Test_Case} @tab -- GNAT
21248 @item @code{Thread_Local_Storage} @tab -- GNAT
21249 @item @code{Type_Invariant} @tab
21250 @item @code{Unchecked_Union} @tab
21251 @item @code{Universal_Aliasing} @tab -- GNAT
21252 @item @code{Unmodified} @tab -- GNAT
21253 @item @code{Unreferenced} @tab -- GNAT
21254 @item @code{Unreferenced_Objects} @tab -- GNAT
21255 @item @code{Unsuppress} @tab
21256 @item @code{Value_Size} @tab -- GNAT
21257 @item @code{Volatile} @tab
21258 @item @code{Volatile_Components}
21259 @item @code{Warnings} @tab -- GNAT
21260 @end multitable
21261
21262 @noindent
21263 Note that for aspects with an expression, e.g. @code{Size}, the expression is
21264 treated like a default expression (visibility is analyzed at the point of
21265 occurrence of the aspect, but evaluation of the expression occurs at the
21266 freeze point of the entity involved).
21267
21268 @noindent
21269 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
21270 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
21271 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
21272 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
21273 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
21274 13.03.01 (0)
21275
21276
21277 @item
21278 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
21279 @cindex AI-0128 (Ada 2012 feature)
21280
21281 @noindent
21282 If an equality operator ("=") is declared for a type, then the implicitly
21283 declared inequality operator ("/=") is a primitive operation of the type.
21284 This is the only reasonable interpretation, and is the one always implemented
21285 by GNAT, but the RM was not entirely clear in making this point.
21286
21287 @noindent
21288 RM References: 3.02.03 (6) 6.06 (6)
21289
21290 @item
21291 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
21292 @cindex AI-0003 (Ada 2012 feature)
21293
21294 @noindent
21295 In Ada 2012, a qualified expression is considered to be syntactically a name,
21296 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
21297 useful in disambiguating some cases of overloading.
21298
21299 @noindent
21300 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
21301 5.04 (7)
21302
21303 @item
21304 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
21305 @cindex AI-0120 (Ada 2012 feature)
21306
21307 @noindent
21308 This is an RM editorial change only. The section that lists objects that are
21309 constant failed to include the current instance of a protected object
21310 within a protected function. This has always been treated as a constant
21311 in GNAT.
21312
21313 @noindent
21314 RM References: 3.03 (21)
21315
21316 @item
21317 @emph{AI-0008 General access to constrained objects (0000-00-00)}
21318 @cindex AI-0008 (Ada 2012 feature)
21319
21320 @noindent
21321 The wording in the RM implied that if you have a general access to a
21322 constrained object, it could be used to modify the discriminants. This was
21323 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
21324 has always done so in this situation.
21325
21326 @noindent
21327 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
21328
21329
21330 @item
21331 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
21332 @cindex AI-0093 (Ada 2012 feature)
21333
21334 @noindent
21335 This is an editorial change only, to make more widespread use of the Ada 2012
21336 ``immutably limited''.
21337
21338 @noindent
21339 RM References: 3.03 (23.4/3)
21340
21341
21342
21343 @item
21344 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
21345 @cindex AI-0096 (Ada 2012 feature)
21346
21347 @noindent
21348 In general it is illegal for a type derived from a formal limited type to be
21349 nonlimited. This AI makes an exception to this rule: derivation is legal
21350 if it appears in the private part of the generic, and the formal type is not
21351 tagged. If the type is tagged, the legality check must be applied to the
21352 private part of the package.
21353
21354 @noindent
21355 RM References: 3.04 (5.1/2) 6.02 (7)
21356
21357
21358 @item
21359 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
21360 @cindex AI-0181 (Ada 2012 feature)
21361
21362 @noindent
21363 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
21364 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
21365 @code{Image} and @code{Value} attributes for the character types. Strictly
21366 speaking this is an inconsistency with Ada 95, but in practice the use of
21367 these attributes is so obscure that it will not cause problems.
21368
21369 @noindent
21370 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
21371
21372
21373 @item
21374 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
21375 @cindex AI-0182 (Ada 2012 feature)
21376
21377 @noindent
21378 This AI allows @code{Character'Value} to accept the string @code{'?'} where
21379 @code{?} is any character including non-graphic control characters. GNAT has
21380 always accepted such strings. It also allows strings such as
21381 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
21382 permission and raises @code{Constraint_Error}, as is certainly still
21383 permitted.
21384
21385 @noindent
21386 RM References: 3.05 (56/2)
21387
21388
21389 @item
21390 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
21391 @cindex AI-0214 (Ada 2012 feature)
21392
21393 @noindent
21394 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
21395 to have default expressions by allowing them when the type is limited. It
21396 is often useful to define a default value for a discriminant even though
21397 it can't be changed by assignment.
21398
21399 @noindent
21400 RM References: 3.07 (9.1/2) 3.07.02 (3)
21401
21402
21403 @item
21404 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
21405 @cindex AI-0102 (Ada 2012 feature)
21406
21407 @noindent
21408 It is illegal to assign an anonymous access constant to an anonymous access
21409 variable. The RM did not have a clear rule to prevent this, but GNAT has
21410 always generated an error for this usage.
21411
21412 @noindent
21413 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
21414
21415
21416 @item
21417 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
21418 @cindex AI-0158 (Ada 2012 feature)
21419
21420 @noindent
21421 This AI extends the syntax of membership tests to simplify complex conditions
21422 that can be expressed as membership in a subset of values of any type. It
21423 introduces syntax for a list of expressions that may be used in loop contexts
21424 as well.
21425
21426 @noindent
21427 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
21428
21429
21430 @item
21431 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
21432 @cindex AI-0173 (Ada 2012 feature)
21433
21434 @noindent
21435 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
21436 with the tag of an abstract type, and @code{False} otherwise.
21437
21438 @noindent
21439 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
21440
21441
21442
21443 @item
21444 @emph{AI-0076 function with controlling result (0000-00-00)}
21445 @cindex AI-0076 (Ada 2012 feature)
21446
21447 @noindent
21448 This is an editorial change only. The RM defines calls with controlling
21449 results, but uses the term ``function with controlling result'' without an
21450 explicit definition.
21451
21452 @noindent
21453 RM References: 3.09.02 (2/2)
21454
21455
21456 @item
21457 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
21458 @cindex AI-0126 (Ada 2012 feature)
21459
21460 @noindent
21461 This AI clarifies dispatching rules, and simply confirms that dispatching
21462 executes the operation of the parent type when there is no explicitly or
21463 implicitly declared operation for the descendant type. This has always been
21464 the case in all versions of GNAT.
21465
21466 @noindent
21467 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
21468
21469
21470 @item
21471 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
21472 @cindex AI-0097 (Ada 2012 feature)
21473
21474 @noindent
21475 The RM as written implied that in some cases it was possible to create an
21476 object of an abstract type, by having an abstract extension inherit a non-
21477 abstract constructor from its parent type. This mistake has been corrected
21478 in GNAT and in the RM, and this construct is now illegal.
21479
21480 @noindent
21481 RM References: 3.09.03 (4/2)
21482
21483
21484 @item
21485 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
21486 @cindex AI-0203 (Ada 2012 feature)
21487
21488 @noindent
21489 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
21490 permitted such usage.
21491
21492 @noindent
21493 RM References: 3.09.03 (8/3)
21494
21495
21496 @item
21497 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
21498 @cindex AI-0198 (Ada 2012 feature)
21499
21500 @noindent
21501 This AI resolves a conflict between two rules involving inherited abstract
21502 operations and predefined operators. If a derived numeric type inherits
21503 an abstract operator, it overrides the predefined one. This interpretation
21504 was always the one implemented in GNAT.
21505
21506 @noindent
21507 RM References: 3.09.03 (4/3)
21508
21509 @item
21510 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
21511 @cindex AI-0073 (Ada 2012 feature)
21512
21513 @noindent
21514 This AI covers a number of issues regarding returning abstract types. In
21515 particular generic functions cannot have abstract result types or access
21516 result types designated an abstract type. There are some other cases which
21517 are detailed in the AI. Note that this binding interpretation has not been
21518 retrofitted to operate before Ada 2012 mode, since it caused a significant
21519 number of regressions.
21520
21521 @noindent
21522 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
21523
21524
21525 @item
21526 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
21527 @cindex AI-0070 (Ada 2012 feature)
21528
21529 @noindent
21530 This is an editorial change only, there are no testable consequences short of
21531 checking for the absence of generated code for an interface declaration.
21532
21533 @noindent
21534 RM References: 3.09.04 (18/2)
21535
21536
21537 @item
21538 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
21539 @cindex AI-0208 (Ada 2012 feature)
21540
21541 @noindent
21542 The wording in the Ada 2005 RM concerning characteristics of incomplete views
21543 was incorrect and implied that some programs intended to be legal were now
21544 illegal. GNAT had never considered such programs illegal, so it has always
21545 implemented the intent of this AI.
21546
21547 @noindent
21548 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
21549
21550
21551 @item
21552 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
21553 @cindex AI-0162 (Ada 2012 feature)
21554
21555 @noindent
21556 Incomplete types are made more useful by allowing them to be completed by
21557 private types and private extensions.
21558
21559 @noindent
21560 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
21561
21562
21563
21564 @item
21565 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
21566 @cindex AI-0098 (Ada 2012 feature)
21567
21568 @noindent
21569 An unintentional omission in the RM implied some inconsistent restrictions on
21570 the use of anonymous access to subprogram values. These restrictions were not
21571 intentional, and have never been enforced by GNAT.
21572
21573 @noindent
21574 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
21575
21576
21577 @item
21578 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
21579 @cindex AI-0199 (Ada 2012 feature)
21580
21581 @noindent
21582 A choice list in a record aggregate can include several components of
21583 (distinct) anonymous access types as long as they have matching designated
21584 subtypes.
21585
21586 @noindent
21587 RM References: 4.03.01 (16)
21588
21589
21590 @item
21591 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
21592 @cindex AI-0220 (Ada 2012 feature)
21593
21594 @noindent
21595 This AI addresses a wording problem in the RM that appears to permit some
21596 complex cases of aggregates with non-static discriminants. GNAT has always
21597 implemented the intended semantics.
21598
21599 @noindent
21600 RM References: 4.03.01 (17)
21601
21602 @item
21603 @emph{AI-0147 Conditional expressions (2009-03-29)}
21604 @cindex AI-0147 (Ada 2012 feature)
21605
21606 @noindent
21607 Conditional expressions are permitted. The form of such an expression is:
21608
21609 @smallexample
21610 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
21611 @end smallexample
21612
21613 The parentheses can be omitted in contexts where parentheses are present
21614 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
21615 clause is omitted, @b{else True} is assumed;
21616 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
21617 @emph{(A implies B)} in standard logic.
21618
21619 @noindent
21620 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
21621 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
21622
21623
21624 @item
21625 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
21626 @cindex AI-0037 (Ada 2012 feature)
21627
21628 @noindent
21629 This AI confirms that an association of the form @code{Indx => <>} in an
21630 array aggregate must raise @code{Constraint_Error} if @code{Indx}
21631 is out of range. The RM specified a range check on other associations, but
21632 not when the value of the association was defaulted. GNAT has always inserted
21633 a constraint check on the index value.
21634
21635 @noindent
21636 RM References: 4.03.03 (29)
21637
21638
21639 @item
21640 @emph{AI-0123 Composability of equality (2010-04-13)}
21641 @cindex AI-0123 (Ada 2012 feature)
21642
21643 @noindent
21644 Equality of untagged record composes, so that the predefined equality for a
21645 composite type that includes a component of some untagged record type
21646 @code{R} uses the equality operation of @code{R} (which may be user-defined
21647 or predefined). This makes the behavior of untagged records identical to that
21648 of tagged types in this respect.
21649
21650 This change is an incompatibility with previous versions of Ada, but it
21651 corrects a non-uniformity that was often a source of confusion. Analysis of
21652 a large number of industrial programs indicates that in those rare cases
21653 where a composite type had an untagged record component with a user-defined
21654 equality, either there was no use of the composite equality, or else the code
21655 expected the same composability as for tagged types, and thus had a bug that
21656 would be fixed by this change.
21657
21658 @noindent
21659 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
21660 8.05.04 (8)
21661
21662
21663 @item
21664 @emph{AI-0088 The value of exponentiation (0000-00-00)}
21665 @cindex AI-0088 (Ada 2012 feature)
21666
21667 @noindent
21668 This AI clarifies the equivalence rule given for the dynamic semantics of
21669 exponentiation: the value of the operation can be obtained by repeated
21670 multiplication, but the operation can be implemented otherwise (for example
21671 using the familiar divide-by-two-and-square algorithm, even if this is less
21672 accurate), and does not imply repeated reads of a volatile base.
21673
21674 @noindent
21675 RM References: 4.05.06 (11)
21676
21677 @item
21678 @emph{AI-0188 Case expressions (2010-01-09)}
21679 @cindex AI-0188 (Ada 2012 feature)
21680
21681 @noindent
21682 Case expressions are permitted. This allows use of constructs such as:
21683 @smallexample
21684 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
21685 @end smallexample
21686
21687 @noindent
21688 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
21689
21690 @item
21691 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
21692 @cindex AI-0104 (Ada 2012 feature)
21693
21694 @noindent
21695 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
21696 @code{Constraint_Error} because the default value of the allocated object is
21697 @b{null}. This useless construct is illegal in Ada 2012.
21698
21699 @noindent
21700 RM References: 4.08 (2)
21701
21702 @item
21703 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
21704 @cindex AI-0157 (Ada 2012 feature)
21705
21706 @noindent
21707 Allocation and Deallocation from an empty storage pool (i.e. allocation or
21708 deallocation of a pointer for which a static storage size clause of zero
21709 has been given) is now illegal and is detected as such. GNAT
21710 previously gave a warning but not an error.
21711
21712 @noindent
21713 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
21714
21715 @item
21716 @emph{AI-0179 Statement not required after label (2010-04-10)}
21717 @cindex AI-0179 (Ada 2012 feature)
21718
21719 @noindent
21720 It is not necessary to have a statement following a label, so a label
21721 can appear at the end of a statement sequence without the need for putting a
21722 null statement afterwards, but it is not allowable to have only labels and
21723 no real statements in a statement sequence.
21724
21725 @noindent
21726 RM References: 5.01 (2)
21727
21728
21729 @item
21730 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
21731 @cindex AI-139-2 (Ada 2012 feature)
21732
21733 @noindent
21734 The new syntax for iterating over arrays and containers is now implemented.
21735 Iteration over containers is for now limited to read-only iterators. Only
21736 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
21737
21738 @noindent
21739 RM References: 5.05
21740
21741 @item
21742 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
21743 @cindex AI-0134 (Ada 2012 feature)
21744
21745 @noindent
21746 For full conformance, the profiles of anonymous-access-to-subprogram
21747 parameters must match. GNAT has always enforced this rule.
21748
21749 @noindent
21750 RM References: 6.03.01 (18)
21751
21752 @item
21753 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
21754 @cindex AI-0207 (Ada 2012 feature)
21755
21756 @noindent
21757 This AI confirms that access_to_constant indication must match for mode
21758 conformance. This was implemented in GNAT when the qualifier was originally
21759 introduced in Ada 2005.
21760
21761 @noindent
21762 RM References: 6.03.01 (16/2)
21763
21764
21765 @item
21766 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
21767 @cindex AI-0046 (Ada 2012 feature)
21768
21769 @noindent
21770 For full conformance, in the case of access parameters, the null exclusion
21771 must match (either both or neither must have @code{@b{not null}}).
21772
21773 @noindent
21774 RM References: 6.03.02 (18)
21775
21776
21777 @item
21778 @emph{AI-0118 The association of parameter associations (0000-00-00)}
21779 @cindex AI-0118 (Ada 2012 feature)
21780
21781 @noindent
21782 This AI clarifies the rules for named associations in subprogram calls and
21783 generic instantiations. The rules have been in place since Ada 83.
21784
21785 @noindent
21786 RM References: 6.04.01 (2) 12.03 (9)
21787
21788
21789 @item
21790 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
21791 @cindex AI-0196 (Ada 2012 feature)
21792
21793 @noindent
21794 Null exclusion checks are not made for @code{@b{out}} parameters when
21795 evaluating the actual parameters. GNAT has never generated these checks.
21796
21797 @noindent
21798 RM References: 6.04.01 (13)
21799
21800 @item
21801 @emph{AI-0015 Constant return objects (0000-00-00)}
21802 @cindex AI-0015 (Ada 2012 feature)
21803
21804 @noindent
21805 The return object declared in an @i{extended_return_statement} may be
21806 declared constant. This was always intended, and GNAT has always allowed it.
21807
21808 @noindent
21809 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
21810 6.05 (5.7/2)
21811
21812
21813 @item
21814 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
21815 @cindex AI-0032 (Ada 2012 feature)
21816
21817 @noindent
21818 If a function returns a class-wide type, the object of an extended return
21819 statement can be declared with a specific type that is covered by the class-
21820 wide type. This has been implemented in GNAT since the introduction of
21821 extended returns. Note AI-0103 complements this AI by imposing matching
21822 rules for constrained return types.
21823
21824 @noindent
21825 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
21826 6.05 (8/2)
21827
21828 @item
21829 @emph{AI-0103 Static matching for extended return (2010-07-23)}
21830 @cindex AI-0103 (Ada 2012 feature)
21831
21832 @noindent
21833 If the return subtype of a function is an elementary type or a constrained
21834 type, the subtype indication in an extended return statement must match
21835 statically this return subtype.
21836
21837 @noindent
21838 RM References: 6.05 (5.2/2)
21839
21840
21841 @item
21842 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
21843 @cindex AI-0058 (Ada 2012 feature)
21844
21845 @noindent
21846 The RM had some incorrect wording implying wrong treatment of abnormal
21847 completion in an extended return. GNAT has always implemented the intended
21848 correct semantics as described by this AI.
21849
21850 @noindent
21851 RM References: 6.05 (22/2)
21852
21853
21854 @item
21855 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
21856 @cindex AI-0050 (Ada 2012 feature)
21857
21858 @noindent
21859 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
21860 not take advantage of these incorrect permissions in any case.
21861
21862 @noindent
21863 RM References: 6.05 (24/2)
21864
21865
21866 @item
21867 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
21868 @cindex AI-0125 (Ada 2012 feature)
21869
21870 @noindent
21871 In Ada 2012, the declaration of a primitive operation of a type extension
21872 or private extension can also override an inherited primitive that is not
21873 visible at the point of this declaration.
21874
21875 @noindent
21876 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
21877
21878 @item
21879 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
21880 @cindex AI-0062 (Ada 2012 feature)
21881
21882 @noindent
21883 A full constant may have a null exclusion even if its associated deferred
21884 constant does not. GNAT has always allowed this.
21885
21886 @noindent
21887 RM References: 7.04 (6/2) 7.04 (7.1/2)
21888
21889
21890 @item
21891 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
21892 @cindex AI-0178 (Ada 2012 feature)
21893
21894 @noindent
21895 This AI clarifies the role of incomplete views and plugs an omission in the
21896 RM. GNAT always correctly restricted the use of incomplete views and types.
21897
21898 @noindent
21899 RM References: 7.05 (3/2) 7.05 (6/2)
21900
21901 @item
21902 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
21903 @cindex AI-0087 (Ada 2012 feature)
21904
21905 @noindent
21906 The actual for a formal nonlimited derived type cannot be limited. In
21907 particular, a formal derived type that extends a limited interface but which
21908 is not explicitly limited cannot be instantiated with a limited type.
21909
21910 @noindent
21911 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
21912
21913 @item
21914 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
21915 @cindex AI-0099 (Ada 2012 feature)
21916
21917 @noindent
21918 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
21919 and therefore depends on the run-time characteristics of an object (i.e. its
21920 tag) and not on its nominal type. As the AI indicates: ``we do not expect
21921 this to affect any implementation''.
21922
21923 @noindent
21924 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
21925
21926
21927
21928 @item
21929 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
21930 @cindex AI-0064 (Ada 2012 feature)
21931
21932 @noindent
21933 This is an editorial change only. The intended behavior is already checked
21934 by an existing ACATS test, which GNAT has always executed correctly.
21935
21936 @noindent
21937 RM References: 7.06.01 (17.1/1)
21938
21939 @item
21940 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
21941 @cindex AI-0026 (Ada 2012 feature)
21942
21943 @noindent
21944 Record representation clauses concerning Unchecked_Union types cannot mention
21945 the discriminant of the type. The type of a component declared in the variant
21946 part of an Unchecked_Union cannot be controlled, have controlled components,
21947 nor have protected or task parts. If an Unchecked_Union type is declared
21948 within the body of a generic unit or its descendants, then the type of a
21949 component declared in the variant part cannot be a formal private type or a
21950 formal private extension declared within the same generic unit.
21951
21952 @noindent
21953 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
21954
21955
21956 @item
21957 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
21958 @cindex AI-0205 (Ada 2012 feature)
21959
21960 @noindent
21961 This AI corrects a simple omission in the RM. Return objects have always
21962 been visible within an extended return statement.
21963
21964 @noindent
21965 RM References: 8.03 (17)
21966
21967
21968 @item
21969 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
21970 @cindex AI-0042 (Ada 2012 feature)
21971
21972 @noindent
21973 This AI fixes a wording gap in the RM. An operation of a synchronized
21974 interface can be implemented by a protected or task entry, but the abstract
21975 operation is not being overridden in the usual sense, and it must be stated
21976 separately that this implementation is legal. This has always been the case
21977 in GNAT.
21978
21979 @noindent
21980 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
21981
21982 @item
21983 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
21984 @cindex AI-0030 (Ada 2012 feature)
21985
21986 @noindent
21987 Requeue is permitted to a protected, synchronized or task interface primitive
21988 providing it is known that the overriding operation is an entry. Otherwise
21989 the requeue statement has the same effect as a procedure call. Use of pragma
21990 @code{Implemented} provides a way to impose a static requirement on the
21991 overriding operation by adhering to one of the implementation kinds: entry,
21992 protected procedure or any of the above.
21993
21994 @noindent
21995 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
21996 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
21997
21998
21999 @item
22000 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
22001 @cindex AI-0201 (Ada 2012 feature)
22002
22003 @noindent
22004 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
22005 attribute, then individual components may not be addressable by independent
22006 tasks. However, if the representation clause has no effect (is confirming),
22007 then independence is not compromised. Furthermore, in GNAT, specification of
22008 other appropriately addressable component sizes (e.g. 16 for 8-bit
22009 characters) also preserves independence. GNAT now gives very clear warnings
22010 both for the declaration of such a type, and for any assignment to its components.
22011
22012 @noindent
22013 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
22014
22015 @item
22016 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
22017 @cindex AI-0009 (Ada 2012 feature)
22018
22019 @noindent
22020 This AI introduces the new pragmas @code{Independent} and
22021 @code{Independent_Components},
22022 which control guaranteeing independence of access to objects and components.
22023 The AI also requires independence not unaffected by confirming rep clauses.
22024
22025 @noindent
22026 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
22027 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
22028
22029
22030 @item
22031 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
22032 @cindex AI-0072 (Ada 2012 feature)
22033
22034 @noindent
22035 This AI clarifies that task signalling for reading @code{'Terminated} only
22036 occurs if the result is True. GNAT semantics has always been consistent with
22037 this notion of task signalling.
22038
22039 @noindent
22040 RM References: 9.10 (6.1/1)
22041
22042 @item
22043 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
22044 @cindex AI-0108 (Ada 2012 feature)
22045
22046 @noindent
22047 This AI confirms that an incomplete type from a limited view does not have
22048 discriminants. This has always been the case in GNAT.
22049
22050 @noindent
22051 RM References: 10.01.01 (12.3/2)
22052
22053 @item
22054 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
22055 @cindex AI-0129 (Ada 2012 feature)
22056
22057 @noindent
22058 This AI clarifies the description of limited views: a limited view of a
22059 package includes only one view of a type that has an incomplete declaration
22060 and a full declaration (there is no possible ambiguity in a client package).
22061 This AI also fixes an omission: a nested package in the private part has no
22062 limited view. GNAT always implemented this correctly.
22063
22064 @noindent
22065 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
22066
22067
22068
22069 @item
22070 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
22071 @cindex AI-0077 (Ada 2012 feature)
22072
22073 @noindent
22074 This AI clarifies that a declaration does not include a context clause,
22075 and confirms that it is illegal to have a context in which both a limited
22076 and a nonlimited view of a package are accessible. Such double visibility
22077 was always rejected by GNAT.
22078
22079 @noindent
22080 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
22081
22082 @item
22083 @emph{AI-0122 Private with and children of generics (0000-00-00)}
22084 @cindex AI-0122 (Ada 2012 feature)
22085
22086 @noindent
22087 This AI clarifies the visibility of private children of generic units within
22088 instantiations of a parent. GNAT has always handled this correctly.
22089
22090 @noindent
22091 RM References: 10.01.02 (12/2)
22092
22093
22094
22095 @item
22096 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
22097 @cindex AI-0040 (Ada 2012 feature)
22098
22099 @noindent
22100 This AI confirms that a limited with clause in a child unit cannot name
22101 an ancestor of the unit. This has always been checked in GNAT.
22102
22103 @noindent
22104 RM References: 10.01.02 (20/2)
22105
22106 @item
22107 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
22108 @cindex AI-0132 (Ada 2012 feature)
22109
22110 @noindent
22111 This AI fills a gap in the description of library unit pragmas. The pragma
22112 clearly must apply to a library unit, even if it does not carry the name
22113 of the enclosing unit. GNAT has always enforced the required check.
22114
22115 @noindent
22116 RM References: 10.01.05 (7)
22117
22118
22119 @item
22120 @emph{AI-0034 Categorization of limited views (0000-00-00)}
22121 @cindex AI-0034 (Ada 2012 feature)
22122
22123 @noindent
22124 The RM makes certain limited with clauses illegal because of categorization
22125 considerations, when the corresponding normal with would be legal. This is
22126 not intended, and GNAT has always implemented the recommended behavior.
22127
22128 @noindent
22129 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
22130
22131
22132 @item
22133 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
22134 @cindex AI-0035 (Ada 2012 feature)
22135
22136 @noindent
22137 This AI remedies some inconsistencies in the legality rules for Pure units.
22138 Derived access types are legal in a pure unit (on the assumption that the
22139 rule for a zero storage pool size has been enforced on the ancestor type).
22140 The rules are enforced in generic instances and in subunits. GNAT has always
22141 implemented the recommended behavior.
22142
22143 @noindent
22144 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)
22145
22146
22147 @item
22148 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
22149 @cindex AI-0219 (Ada 2012 feature)
22150
22151 @noindent
22152 This AI refines the rules for the cases with limited parameters which do not
22153 allow the implementations to omit ``redundant''. GNAT now properly conforms
22154 to the requirements of this binding interpretation.
22155
22156 @noindent
22157 RM References: 10.02.01 (18/2)
22158
22159 @item
22160 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
22161 @cindex AI-0043 (Ada 2012 feature)
22162
22163 @noindent
22164 This AI covers various omissions in the RM regarding the raising of
22165 exceptions. GNAT has always implemented the intended semantics.
22166
22167 @noindent
22168 RM References: 11.04.01 (10.1/2) 11 (2)
22169
22170
22171 @item
22172 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
22173 @cindex AI-0200 (Ada 2012 feature)
22174
22175 @noindent
22176 This AI plugs a gap in the RM which appeared to allow some obviously intended
22177 illegal instantiations. GNAT has never allowed these instantiations.
22178
22179 @noindent
22180 RM References: 12.07 (16)
22181
22182
22183 @item
22184 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
22185 @cindex AI-0112 (Ada 2012 feature)
22186
22187 @noindent
22188 This AI concerns giving names to various representation aspects, but the
22189 practical effect is simply to make the use of duplicate
22190 @code{Atomic}[@code{_Components}],
22191 @code{Volatile}[@code{_Components}] and
22192 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
22193 now performs this required check.
22194
22195 @noindent
22196 RM References: 13.01 (8)
22197
22198 @item
22199 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
22200 @cindex AI-0106 (Ada 2012 feature)
22201
22202 @noindent
22203 The RM appeared to allow representation pragmas on generic formal parameters,
22204 but this was not intended, and GNAT has never permitted this usage.
22205
22206 @noindent
22207 RM References: 13.01 (9.1/1)
22208
22209
22210 @item
22211 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
22212 @cindex AI-0012 (Ada 2012 feature)
22213
22214 @noindent
22215 It is now illegal to give an inappropriate component size or a pragma
22216 @code{Pack} that attempts to change the component size in the case of atomic
22217 or aliased components. Previously GNAT ignored such an attempt with a
22218 warning.
22219
22220 @noindent
22221 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
22222
22223
22224 @item
22225 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
22226 @cindex AI-0039 (Ada 2012 feature)
22227
22228 @noindent
22229 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
22230 for stream attributes, but these were never useful and are now illegal. GNAT
22231 has always regarded such expressions as illegal.
22232
22233 @noindent
22234 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
22235
22236
22237 @item
22238 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
22239 @cindex AI-0095 (Ada 2012 feature)
22240
22241 @noindent
22242 The prefix of @code{'Address} cannot statically denote a subprogram with
22243 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
22244 @code{Program_Error} if the prefix denotes a subprogram with convention
22245 @code{Intrinsic}.
22246
22247 @noindent
22248 RM References: 13.03 (11/1)
22249
22250
22251 @item
22252 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
22253 @cindex AI-0116 (Ada 2012 feature)
22254
22255 @noindent
22256 This AI requires that the alignment of a class-wide object be no greater
22257 than the alignment of any type in the class. GNAT has always followed this
22258 recommendation.
22259
22260 @noindent
22261 RM References: 13.03 (29) 13.11 (16)
22262
22263
22264 @item
22265 @emph{AI-0146 Type invariants (2009-09-21)}
22266 @cindex AI-0146 (Ada 2012 feature)
22267
22268 @noindent
22269 Type invariants may be specified for private types using the aspect notation.
22270 Aspect @code{Type_Invariant} may be specified for any private type,
22271 @code{Type_Invariant'Class} can
22272 only be specified for tagged types, and is inherited by any descendent of the
22273 tagged types. The invariant is a boolean expression that is tested for being
22274 true in the following situations: conversions to the private type, object
22275 declarations for the private type that are default initialized, and
22276 [@b{in}] @b{out}
22277 parameters and returned result on return from any primitive operation for
22278 the type that is visible to a client.
22279 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
22280 @code{Invariant'Class} for @code{Type_Invariant'Class}.
22281
22282 @noindent
22283 RM References: 13.03.03 (00)
22284
22285 @item
22286 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
22287 @cindex AI-0078 (Ada 2012 feature)
22288
22289 @noindent
22290 In Ada 2012, compilers are required to support unchecked conversion where the
22291 target alignment is a multiple of the source alignment. GNAT always supported
22292 this case (and indeed all cases of differing alignments, doing copies where
22293 required if the alignment was reduced).
22294
22295 @noindent
22296 RM References: 13.09 (7)
22297
22298
22299 @item
22300 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
22301 @cindex AI-0195 (Ada 2012 feature)
22302
22303 @noindent
22304 The handling of invalid values is now designated to be implementation
22305 defined. This is a documentation change only, requiring Annex M in the GNAT
22306 Reference Manual to document this handling.
22307 In GNAT, checks for invalid values are made
22308 only when necessary to avoid erroneous behavior. Operations like assignments
22309 which cannot cause erroneous behavior ignore the possibility of invalid
22310 values and do not do a check. The date given above applies only to the
22311 documentation change, this behavior has always been implemented by GNAT.
22312
22313 @noindent
22314 RM References: 13.09.01 (10)
22315
22316 @item
22317 @emph{AI-0193 Alignment of allocators (2010-09-16)}
22318 @cindex AI-0193 (Ada 2012 feature)
22319
22320 @noindent
22321 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
22322 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
22323 of size.
22324
22325 @noindent
22326 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
22327 13.11.01 (2) 13.11.01 (3)
22328
22329
22330 @item
22331 @emph{AI-0177 Parameterized expressions (2010-07-10)}
22332 @cindex AI-0177 (Ada 2012 feature)
22333
22334 @noindent
22335 The new Ada 2012 notion of parameterized expressions is implemented. The form
22336 is:
22337 @smallexample
22338 @i{function specification} @b{is} (@i{expression})
22339 @end smallexample
22340
22341 @noindent
22342 This is exactly equivalent to the
22343 corresponding function body that returns the expression, but it can appear
22344 in a package spec. Note that the expression must be parenthesized.
22345
22346 @noindent
22347 RM References: 13.11.01 (3/2)
22348
22349 @item
22350 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
22351 @cindex AI-0033 (Ada 2012 feature)
22352
22353 @noindent
22354 Neither of these two pragmas may appear within a generic template, because
22355 the generic might be instantiated at other than the library level.
22356
22357 @noindent
22358 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
22359
22360
22361 @item
22362 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
22363 @cindex AI-0161 (Ada 2012 feature)
22364
22365 @noindent
22366 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
22367 of the default stream attributes for elementary types. If this restriction is
22368 in force, then it is necessary to provide explicit subprograms for any
22369 stream attributes used.
22370
22371 @noindent
22372 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
22373
22374 @item
22375 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
22376 @cindex AI-0194 (Ada 2012 feature)
22377
22378 @noindent
22379 The @code{Stream_Size} attribute returns the default number of bits in the
22380 stream representation of the given type.
22381 This value is not affected by the presence
22382 of stream subprogram attributes for the type. GNAT has always implemented
22383 this interpretation.
22384
22385 @noindent
22386 RM References: 13.13.02 (1.2/2)
22387
22388 @item
22389 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
22390 @cindex AI-0109 (Ada 2012 feature)
22391
22392 @noindent
22393 This AI is an editorial change only. It removes the need for a tag check
22394 that can never fail.
22395
22396 @noindent
22397 RM References: 13.13.02 (34/2)
22398
22399 @item
22400 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
22401 @cindex AI-0007 (Ada 2012 feature)
22402
22403 @noindent
22404 The RM as written appeared to limit the possibilities of declaring read
22405 attribute procedures for private scalar types. This limitation was not
22406 intended, and has never been enforced by GNAT.
22407
22408 @noindent
22409 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
22410
22411
22412 @item
22413 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
22414 @cindex AI-0065 (Ada 2012 feature)
22415
22416 @noindent
22417 This AI clarifies the fact that all remote access types support external
22418 streaming. This fixes an obvious oversight in the definition of the
22419 language, and GNAT always implemented the intended correct rules.
22420
22421 @noindent
22422 RM References: 13.13.02 (52/2)
22423
22424 @item
22425 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
22426 @cindex AI-0019 (Ada 2012 feature)
22427
22428 @noindent
22429 The RM suggests that primitive subprograms of a specific tagged type are
22430 frozen when the tagged type is frozen. This would be an incompatible change
22431 and is not intended. GNAT has never attempted this kind of freezing and its
22432 behavior is consistent with the recommendation of this AI.
22433
22434 @noindent
22435 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)
22436
22437 @item
22438 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
22439 @cindex AI-0017 (Ada 2012 feature)
22440
22441 @noindent
22442 So-called ``Taft-amendment types'' (i.e., types that are completed in package
22443 bodies) are not frozen by the occurrence of bodies in the
22444 enclosing declarative part. GNAT always implemented this properly.
22445
22446 @noindent
22447 RM References: 13.14 (3/1)
22448
22449
22450 @item
22451 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
22452 @cindex AI-0060 (Ada 2012 feature)
22453
22454 @noindent
22455 This AI extends the definition of remote access types to include access
22456 to limited, synchronized, protected or task class-wide interface types.
22457 GNAT already implemented this extension.
22458
22459 @noindent
22460 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
22461
22462 @item
22463 @emph{AI-0114 Classification of letters (0000-00-00)}
22464 @cindex AI-0114 (Ada 2012 feature)
22465
22466 @noindent
22467 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
22468 181 (@code{MICRO SIGN}), and
22469 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
22470 lower case letters by Unicode.
22471 However, they are not allowed in identifiers, and they
22472 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
22473 This behavior is consistent with that defined in Ada 95.
22474
22475 @noindent
22476 RM References: A.03.02 (59) A.04.06 (7)
22477
22478
22479 @item
22480 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
22481 @cindex AI-0185 (Ada 2012 feature)
22482
22483 @noindent
22484 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
22485 classification functions for @code{Wide_Character} and
22486 @code{Wide_Wide_Character}, as well as providing
22487 case folding routines for @code{Wide_[Wide_]Character} and
22488 @code{Wide_[Wide_]String}.
22489
22490 @noindent
22491 RM References: A.03.05 (0) A.03.06 (0)
22492
22493
22494 @item
22495 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
22496 @cindex AI-0031 (Ada 2012 feature)
22497
22498 @noindent
22499 A new version of @code{Find_Token} is added to all relevant string packages,
22500 with an extra parameter @code{From}. Instead of starting at the first
22501 character of the string, the search for a matching Token starts at the
22502 character indexed by the value of @code{From}.
22503 These procedures are available in all versions of Ada
22504 but if used in versions earlier than Ada 2012 they will generate a warning
22505 that an Ada 2012 subprogram is being used.
22506
22507 @noindent
22508 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
22509 A.04.05 (46)
22510
22511
22512 @item
22513 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
22514 @cindex AI-0056 (Ada 2012 feature)
22515
22516 @noindent
22517 The wording in the Ada 2005 RM implied an incompatible handling of the
22518 @code{Index} functions, resulting in raising an exception instead of
22519 returning zero in some situations.
22520 This was not intended and has been corrected.
22521 GNAT always returned zero, and is thus consistent with this AI.
22522
22523 @noindent
22524 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
22525
22526
22527 @item
22528 @emph{AI-0137 String encoding package (2010-03-25)}
22529 @cindex AI-0137 (Ada 2012 feature)
22530
22531 @noindent
22532 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
22533 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
22534 and @code{Wide_Wide_Strings} have been
22535 implemented. These packages (whose documentation can be found in the spec
22536 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
22537 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
22538 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
22539 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
22540 UTF-16), as well as conversions between the different UTF encodings. With
22541 the exception of @code{Wide_Wide_Strings}, these packages are available in
22542 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
22543 The @code{Wide_Wide_Strings package}
22544 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
22545 mode since it uses @code{Wide_Wide_Character}).
22546
22547 @noindent
22548 RM References: A.04.11
22549
22550 @item
22551 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
22552 @cindex AI-0038 (Ada 2012 feature)
22553
22554 @noindent
22555 These are minor errors in the description on three points. The intent on
22556 all these points has always been clear, and GNAT has always implemented the
22557 correct intended semantics.
22558
22559 @noindent
22560 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)
22561
22562 @item
22563 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
22564 @cindex AI-0044 (Ada 2012 feature)
22565
22566 @noindent
22567 This AI places restrictions on allowed instantiations of generic containers.
22568 These restrictions are not checked by the compiler, so there is nothing to
22569 change in the implementation. This affects only the RM documentation.
22570
22571 @noindent
22572 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)
22573
22574 @item
22575 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
22576 @cindex AI-0127 (Ada 2012 feature)
22577
22578 @noindent
22579 This package provides an interface for identifying the current locale.
22580
22581 @noindent
22582 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
22583 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
22584
22585
22586
22587 @item
22588 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
22589 @cindex AI-0002 (Ada 2012 feature)
22590
22591 @noindent
22592 The compiler is not required to support exporting an Ada subprogram with
22593 convention C if there are parameters or a return type of an unconstrained
22594 array type (such as @code{String}). GNAT allows such declarations but
22595 generates warnings. It is possible, but complicated, to write the
22596 corresponding C code and certainly such code would be specific to GNAT and
22597 non-portable.
22598
22599 @noindent
22600 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
22601
22602
22603 @item
22604 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
22605 @cindex AI05-0216 (Ada 2012 feature)
22606
22607 @noindent
22608 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
22609 forbid tasks declared locally within subprograms, or functions returning task
22610 objects, and that is the implementation that GNAT has always provided.
22611 However the language in the RM was not sufficiently clear on this point.
22612 Thus this is a documentation change in the RM only.
22613
22614 @noindent
22615 RM References: D.07 (3/3)
22616
22617 @item
22618 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
22619 @cindex AI-0211 (Ada 2012 feature)
22620
22621 @noindent
22622 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
22623 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
22624
22625 @noindent
22626 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
22627
22628 @item
22629 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
22630 @cindex AI-0190 (Ada 2012 feature)
22631
22632 @noindent
22633 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
22634 used to control storage pools globally.
22635 In particular, you can force every access
22636 type that is used for allocation (@b{new}) to have an explicit storage pool,
22637 or you can declare a pool globally to be used for all access types that lack
22638 an explicit one.
22639
22640 @noindent
22641 RM References: D.07 (8)
22642
22643 @item
22644 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
22645 @cindex AI-0189 (Ada 2012 feature)
22646
22647 @noindent
22648 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
22649 which says that no dynamic allocation will occur once elaboration is
22650 completed.
22651 In general this requires a run-time check, which is not required, and which
22652 GNAT does not attempt. But the static cases of allocators in a task body or
22653 in the body of the main program are detected and flagged at compile or bind
22654 time.
22655
22656 @noindent
22657 RM References: D.07 (19.1/2) H.04 (23.3/2)
22658
22659 @item
22660 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
22661 @cindex AI-0171 (Ada 2012 feature)
22662
22663 @noindent
22664 A new package @code{System.Multiprocessors} is added, together with the
22665 definition of pragma @code{CPU} for controlling task affinity. A new no
22666 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
22667 is added to the Ravenscar profile.
22668
22669 @noindent
22670 RM References: D.13.01 (4/2) D.16
22671
22672
22673 @item
22674 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
22675 @cindex AI-0210 (Ada 2012 feature)
22676
22677 @noindent
22678 This is a documentation only issue regarding wording of metric requirements,
22679 that does not affect the implementation of the compiler.
22680
22681 @noindent
22682 RM References: D.15 (24/2)
22683
22684
22685 @item
22686 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
22687 @cindex AI-0206 (Ada 2012 feature)
22688
22689 @noindent
22690 Remote types packages are now allowed to depend on preelaborated packages.
22691 This was formerly considered illegal.
22692
22693 @noindent
22694 RM References: E.02.02 (6)
22695
22696
22697
22698 @item
22699 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
22700 @cindex AI-0152 (Ada 2012 feature)
22701
22702 @noindent
22703 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
22704 where the type of the returned value is an anonymous access type.
22705
22706 @noindent
22707 RM References: H.04 (8/1)
22708 @end itemize
22709
22710
22711 @node Obsolescent Features
22712 @chapter Obsolescent Features
22713
22714 @noindent
22715 This chapter describes features that are provided by GNAT, but are
22716 considered obsolescent since there are preferred ways of achieving
22717 the same effect. These features are provided solely for historical
22718 compatibility purposes.
22719
22720 @menu
22721 * pragma No_Run_Time::
22722 * pragma Ravenscar::
22723 * pragma Restricted_Run_Time::
22724 * pragma Task_Info::
22725 * System.Task_Info (s-tasinf.ads)::
22726 @end menu
22727
22728 @node pragma No_Run_Time
22729 @section pragma No_Run_Time
22730
22731 The pragma @code{No_Run_Time} is used to achieve an affect similar
22732 to the use of the "Zero Foot Print" configurable run time, but without
22733 requiring a specially configured run time. The result of using this
22734 pragma, which must be used for all units in a partition, is to restrict
22735 the use of any language features requiring run-time support code. The
22736 preferred usage is to use an appropriately configured run-time that
22737 includes just those features that are to be made accessible.
22738
22739 @node pragma Ravenscar
22740 @section pragma Ravenscar
22741
22742 The pragma @code{Ravenscar} has exactly the same effect as pragma
22743 @code{Profile (Ravenscar)}. The latter usage is preferred since it
22744 is part of the new Ada 2005 standard.
22745
22746 @node pragma Restricted_Run_Time
22747 @section pragma Restricted_Run_Time
22748
22749 The pragma @code{Restricted_Run_Time} has exactly the same effect as
22750 pragma @code{Profile (Restricted)}. The latter usage is
22751 preferred since the Ada 2005 pragma @code{Profile} is intended for
22752 this kind of implementation dependent addition.
22753
22754 @node pragma Task_Info
22755 @section pragma Task_Info
22756
22757 The functionality provided by pragma @code{Task_Info} is now part of the
22758 Ada language. The @code{CPU} aspect and the package
22759 @code{System.Multiprocessors} offer a less system-dependent way to specify
22760 task affinity or to query the number of processsors.
22761
22762 @noindent
22763 Syntax
22764
22765 @smallexample @c ada
22766 pragma Task_Info (EXPRESSION);
22767 @end smallexample
22768
22769 @noindent
22770 This pragma appears within a task definition (like pragma
22771 @code{Priority}) and applies to the task in which it appears. The
22772 argument must be of type @code{System.Task_Info.Task_Info_Type}.
22773 The @code{Task_Info} pragma provides system dependent control over
22774 aspects of tasking implementation, for example, the ability to map
22775 tasks to specific processors. For details on the facilities available
22776 for the version of GNAT that you are using, see the documentation
22777 in the spec of package System.Task_Info in the runtime
22778 library.
22779
22780 @node System.Task_Info (s-tasinf.ads)
22781 @section package System.Task_Info (@file{s-tasinf.ads})
22782
22783 @noindent
22784 This package provides target dependent functionality that is used
22785 to support the @code{Task_Info} pragma. The predefined Ada package
22786 @code{System.Multiprocessors} and the @code{CPU} aspect now provide a
22787 standard replacement for GNAT's @code{Task_Info} functionality.
22788
22789 @include fdl.texi
22790 @c GNU Free Documentation License
22791
22792 @node Index,,GNU Free Documentation License, Top
22793 @unnumbered Index
22794
22795 @printindex cp
22796
22797 @contents
22798
22799 @bye
22800 tablishes the following set of restrictions:
22801 Pragma Shared