c0bbfb882293dbd3c99f0d4a618ff1790bc5b2b0
[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:Concept Index.
88
89 @detailmenu
90 --- The Detailed Node Listing ---
91
92 About This Guide
93
94 * What This Reference Manual Contains::
95 * Related Information::
96
97 Implementation Defined Pragmas
98
99 * Pragma Abort_Defer::
100 * Pragma Abstract_State::
101 * Pragma Ada_83::
102 * Pragma Ada_95::
103 * Pragma Ada_05::
104 * Pragma Ada_2005::
105 * Pragma Ada_12::
106 * Pragma Ada_2012::
107 * Pragma Allow_Integer_Address::
108 * Pragma Annotate::
109 * Pragma Assert::
110 * Pragma Assert_And_Cut::
111 * Pragma Assertion_Policy::
112 * Pragma Assume::
113 * Pragma Assume_No_Invalid_Values::
114 * Pragma AST_Entry::
115 * Pragma Async_Readers::
116 * Pragma Async_Writers::
117 * Pragma Attribute_Definition::
118 * Pragma C_Pass_By_Copy::
119 * Pragma Check::
120 * Pragma Check_Float_Overflow::
121 * Pragma Check_Name::
122 * Pragma Check_Policy::
123 * Pragma CIL_Constructor::
124 * Pragma Comment::
125 * Pragma Common_Object::
126 * Pragma Compile_Time_Error::
127 * Pragma Compile_Time_Warning::
128 * Pragma Compiler_Unit::
129 * Pragma Compiler_Unit_Warning::
130 * Pragma Complete_Representation::
131 * Pragma Complex_Representation::
132 * Pragma Component_Alignment::
133 * Pragma Contract_Cases::
134 * Pragma Convention_Identifier::
135 * Pragma CPP_Class::
136 * Pragma CPP_Constructor::
137 * Pragma CPP_Virtual::
138 * Pragma CPP_Vtable::
139 * Pragma CPU::
140 * Pragma Debug::
141 * Pragma Debug_Policy::
142 * Pragma Default_Scalar_Storage_Order::
143 * Pragma Default_Storage_Pool::
144 * Pragma Depends::
145 * Pragma Detect_Blocking::
146 * Pragma Disable_Atomic_Synchronization::
147 * Pragma Dispatching_Domain::
148 * Pragma Effective_Reads::
149 * Pragma Effective_Writes::
150 * Pragma Elaboration_Checks::
151 * Pragma Eliminate::
152 * Pragma Enable_Atomic_Synchronization::
153 * Pragma Export_Exception::
154 * Pragma Export_Function::
155 * Pragma Export_Object::
156 * Pragma Export_Procedure::
157 * Pragma Export_Value::
158 * Pragma Export_Valued_Procedure::
159 * Pragma Extend_System::
160 * Pragma Extensions_Allowed::
161 * Pragma External::
162 * Pragma External_Name_Casing::
163 * Pragma Fast_Math::
164 * Pragma Favor_Top_Level::
165 * Pragma Finalize_Storage_Only::
166 * Pragma Float_Representation::
167 * Pragma Global::
168 * Pragma Ident::
169 * Pragma Implementation_Defined::
170 * Pragma Implemented::
171 * Pragma Implicit_Packing::
172 * Pragma Import_Exception::
173 * Pragma Import_Function::
174 * Pragma Import_Object::
175 * Pragma Import_Procedure::
176 * Pragma Import_Valued_Procedure::
177 * Pragma Independent::
178 * Pragma Independent_Components::
179 * Pragma Initial_Condition::
180 * Pragma Initialize_Scalars::
181 * Pragma Initializes::
182 * Pragma Inline_Always::
183 * Pragma Inline_Generic::
184 * Pragma Interface::
185 * Pragma Interface_Name::
186 * Pragma Interrupt_Handler::
187 * Pragma Interrupt_State::
188 * Pragma Invariant::
189 * Pragma Java_Constructor::
190 * Pragma Java_Interface::
191 * Pragma Keep_Names::
192 * Pragma License::
193 * Pragma Link_With::
194 * Pragma Linker_Alias::
195 * Pragma Linker_Constructor::
196 * Pragma Linker_Destructor::
197 * Pragma Linker_Section::
198 * Pragma Lock_Free::
199 * Pragma Long_Float::
200 * Pragma Loop_Invariant::
201 * Pragma Loop_Optimize::
202 * Pragma Loop_Variant::
203 * Pragma Machine_Attribute::
204 * Pragma Main::
205 * Pragma Main_Storage::
206 * Pragma No_Body::
207 * Pragma No_Inline::
208 * Pragma No_Return::
209 * Pragma No_Run_Time::
210 * Pragma No_Strict_Aliasing ::
211 * Pragma Normalize_Scalars::
212 * Pragma Obsolescent::
213 * Pragma Optimize_Alignment::
214 * Pragma Ordered::
215 * Pragma Overflow_Mode::
216 * Pragma Overriding_Renamings::
217 * Pragma Partition_Elaboration_Policy::
218 * Pragma Part_Of::
219 * Pragma Passive::
220 * Pragma Persistent_BSS::
221 * Pragma Polling::
222 * Pragma Post::
223 * Pragma Postcondition::
224 * Pragma Post_Class::
225 * Pragma Pre::
226 * Pragma Precondition::
227 * Pragma Predicate::
228 * Pragma Preelaborable_Initialization::
229 * Pragma Pre_Class::
230 * Pragma Priority_Specific_Dispatching::
231 * Pragma Profile::
232 * Pragma Profile_Warnings::
233 * Pragma Propagate_Exceptions::
234 * Pragma Provide_Shift_Operators::
235 * Pragma Psect_Object::
236 * Pragma Pure_Function::
237 * Pragma Rational::
238 * Pragma Ravenscar::
239 * Pragma Refined_Depends::
240 * Pragma Refined_Global::
241 * Pragma Refined_Post::
242 * Pragma Refined_State::
243 * Pragma Relative_Deadline::
244 * Pragma Remote_Access_Type::
245 * Pragma Restricted_Run_Time::
246 * Pragma Restriction_Warnings::
247 * Pragma Reviewable::
248 * Pragma Share_Generic::
249 * Pragma Shared::
250 * Pragma Short_Circuit_And_Or::
251 * Pragma Short_Descriptors::
252 * Pragma Simple_Storage_Pool_Type::
253 * Pragma Source_File_Name::
254 * Pragma Source_File_Name_Project::
255 * Pragma Source_Reference::
256 * Pragma SPARK_Mode::
257 * Pragma Static_Elaboration_Desired::
258 * Pragma Stream_Convert::
259 * Pragma Style_Checks::
260 * Pragma Subtitle::
261 * Pragma Suppress::
262 * Pragma Suppress_All::
263 * Pragma Suppress_Debug_Info::
264 * Pragma Suppress_Exception_Locations::
265 * Pragma Suppress_Initialization::
266 * Pragma Task_Name::
267 * Pragma Task_Storage::
268 * Pragma Test_Case::
269 * Pragma Thread_Local_Storage::
270 * Pragma Time_Slice::
271 * Pragma Title::
272 * Pragma Type_Invariant::
273 * Pragma Type_Invariant_Class::
274 * Pragma Unchecked_Union::
275 * Pragma Unevaluated_Use_Of_Old::
276 * Pragma Unimplemented_Unit::
277 * Pragma Universal_Aliasing ::
278 * Pragma Universal_Data::
279 * Pragma Unmodified::
280 * Pragma Unreferenced::
281 * Pragma Unreferenced_Objects::
282 * Pragma Unreserve_All_Interrupts::
283 * Pragma Unsuppress::
284 * Pragma Use_VADS_Size::
285 * Pragma Validity_Checks::
286 * Pragma Volatile::
287 * Pragma Warning_As_Error::
288 * Pragma Warnings::
289 * Pragma Weak_External::
290 * Pragma Wide_Character_Encoding::
291
292 Implementation Defined Aspects
293
294 * Aspect Abstract_State::
295 * Aspect Annotate::
296 * Aspect Async_Readers::
297 * Aspect Async_Writers::
298 * Aspect Contract_Cases::
299 * Aspect Depends::
300 * Aspect Dimension::
301 * Aspect Dimension_System::
302 * Aspect Effective_Reads::
303 * Aspect Effective_Writes::
304 * Aspect Favor_Top_Level::
305 * Aspect Global::
306 * Aspect Initial_Condition::
307 * Aspect Initializes::
308 * Aspect Inline_Always::
309 * Aspect Invariant::
310 * Aspect Iterable::
311 * Aspect Linker_Section::
312 * Aspect Object_Size::
313 * Aspect Part_Of::
314 * Aspect Persistent_BSS::
315 * Aspect Predicate::
316 * Aspect Pure_Function::
317 * Aspect Refined_Depends::
318 * Aspect Refined_Global::
319 * Aspect Refined_Post::
320 * Aspect Refined_State::
321 * Aspect Remote_Access_Type::
322 * Aspect Scalar_Storage_Order::
323 * Aspect Shared::
324 * Aspect Simple_Storage_Pool::
325 * Aspect Simple_Storage_Pool_Type::
326 * Aspect SPARK_Mode::
327 * Aspect Suppress_Debug_Info::
328 * Aspect Test_Case::
329 * Aspect Thread_Local_Storage::
330 * Aspect Universal_Aliasing::
331 * Aspect Universal_Data::
332 * Aspect Unmodified::
333 * Aspect Unreferenced::
334 * Aspect Unreferenced_Objects::
335 * Aspect Value_Size::
336 * Aspect Warnings::
337
338 Implementation Defined Attributes
339
340 * Attribute Abort_Signal::
341 * Attribute Address_Size::
342 * Attribute Asm_Input::
343 * Attribute Asm_Output::
344 * Attribute AST_Entry::
345 * Attribute Atomic_Always_Lock_Free::
346 * Attribute Bit::
347 * Attribute Bit_Position::
348 * Attribute Code_Address::
349 * Attribute Compiler_Version::
350 * Attribute Constrained::
351 * Attribute Default_Bit_Order::
352 * Attribute Descriptor_Size::
353 * Attribute Elaborated::
354 * Attribute Elab_Body::
355 * Attribute Elab_Spec::
356 * Attribute Elab_Subp_Body::
357 * Attribute Emax::
358 * Attribute Enabled::
359 * Attribute Enum_Rep::
360 * Attribute Enum_Val::
361 * Attribute Epsilon::
362 * Attribute Fast_Math::
363 * Attribute Fixed_Value::
364 * Attribute From_Any::
365 * Attribute Has_Access_Values::
366 * Attribute Has_Discriminants::
367 * Attribute Img::
368 * Attribute Integer_Value::
369 * Attribute Invalid_Value::
370 * Attribute Iterable::
371 * Attribute Large::
372 * Attribute Library_Level::
373 * Attribute Lock_Free::
374 * Attribute Loop_Entry::
375 * Attribute Machine_Size::
376 * Attribute Mantissa::
377 * Attribute Maximum_Alignment::
378 * Attribute Mechanism_Code::
379 * Attribute Null_Parameter::
380 * Attribute Object_Size::
381 * Attribute Old::
382 * Attribute Passed_By_Reference::
383 * Attribute Pool_Address::
384 * Attribute Range_Length::
385 * Attribute Ref::
386 * Attribute Restriction_Set::
387 * Attribute Result::
388 * Attribute Safe_Emax::
389 * Attribute Safe_Large::
390 * Attribute Safe_Small::
391 * Attribute Scalar_Storage_Order::
392 * Attribute Simple_Storage_Pool::
393 * Attribute Small::
394 * Attribute Storage_Unit::
395 * Attribute Stub_Type::
396 * Attribute System_Allocator_Alignment::
397 * Attribute Target_Name::
398 * Attribute To_Address::
399 * Attribute To_Any::
400 * Attribute Type_Class::
401 * Attribute Type_Key::
402 * Attribute TypeCode::
403 * Attribute UET_Address::
404 * Attribute Unconstrained_Array::
405 * Attribute Universal_Literal_String::
406 * Attribute Unrestricted_Access::
407 * Attribute Update::
408 * Attribute VADS_Size::
409 * Attribute Valid_Scalars::
410 * Attribute Value_Size::
411 * Attribute Wchar_T_Size::
412 * Attribute Word_Size::
413
414 Standard and Implementation Defined Restrictions
415
416 * Partition-Wide Restrictions::
417 * Program Unit Level Restrictions::
418
419 Partition-Wide Restrictions
420
421 * Immediate_Reclamation::
422 * Max_Asynchronous_Select_Nesting::
423 * Max_Entry_Queue_Length::
424 * Max_Protected_Entries::
425 * Max_Select_Alternatives::
426 * Max_Storage_At_Blocking::
427 * Max_Task_Entries::
428 * Max_Tasks::
429 * No_Abort_Statements::
430 * No_Access_Parameter_Allocators::
431 * No_Access_Subprograms::
432 * No_Allocators::
433 * No_Anonymous_Allocators::
434 * No_Calendar::
435 * No_Coextensions::
436 * No_Default_Initialization::
437 * No_Delay::
438 * No_Dependence::
439 * No_Direct_Boolean_Operators::
440 * No_Dispatch::
441 * No_Dispatching_Calls::
442 * No_Dynamic_Attachment::
443 * No_Dynamic_Priorities::
444 * No_Entry_Calls_In_Elaboration_Code::
445 * No_Enumeration_Maps::
446 * No_Exception_Handlers::
447 * No_Exception_Propagation::
448 * No_Exception_Registration::
449 * No_Exceptions::
450 * No_Finalization::
451 * No_Fixed_Point::
452 * No_Floating_Point::
453 * No_Implicit_Conditionals::
454 * No_Implicit_Dynamic_Code::
455 * No_Implicit_Heap_Allocations::
456 * No_Implicit_Loops::
457 * No_Initialize_Scalars::
458 * No_IO::
459 * No_Local_Allocators::
460 * No_Local_Protected_Objects::
461 * No_Local_Timing_Events::
462 * No_Long_Long_Integers::
463 * No_Multiple_Elaboration::
464 * No_Nested_Finalization::
465 * No_Protected_Type_Allocators::
466 * No_Protected_Types::
467 * No_Recursion::
468 * No_Reentrancy::
469 * No_Relative_Delay::
470 * No_Requeue_Statements::
471 * No_Secondary_Stack::
472 * No_Select_Statements::
473 * No_Specific_Termination_Handlers::
474 * No_Specification_of_Aspect::
475 * No_Standard_Allocators_After_Elaboration::
476 * No_Standard_Storage_Pools::
477 * No_Stream_Optimizations::
478 * No_Streams::
479 * No_Task_Allocators::
480 * No_Task_Attributes_Package::
481 * No_Task_Hierarchy::
482 * No_Task_Termination::
483 * No_Tasking::
484 * No_Terminate_Alternatives::
485 * No_Unchecked_Access::
486 * Simple_Barriers::
487 * Static_Priorities::
488 * Static_Storage_Size::
489
490 Program Unit Level Restrictions
491
492 * No_Elaboration_Code::
493 * No_Entry_Queue::
494 * No_Implementation_Aspect_Specifications::
495 * No_Implementation_Attributes::
496 * No_Implementation_Identifiers::
497 * No_Implementation_Pragmas::
498 * No_Implementation_Restrictions::
499 * No_Implementation_Units::
500 * No_Implicit_Aliasing::
501 * No_Obsolescent_Features::
502 * No_Wide_Characters::
503 * SPARK_05::
504
505 The Implementation of Standard I/O
506
507 * Standard I/O Packages::
508 * FORM Strings::
509 * Direct_IO::
510 * Sequential_IO::
511 * Text_IO::
512 * Wide_Text_IO::
513 * Wide_Wide_Text_IO::
514 * Stream_IO::
515 * Text Translation::
516 * Shared Files::
517 * Filenames encoding::
518 * File content encoding::
519 * Open Modes::
520 * Operations on C Streams::
521 * Interfacing to C Streams::
522
523 The GNAT Library
524
525 * Ada.Characters.Latin_9 (a-chlat9.ads)::
526 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
527 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
528 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
529 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
530 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
531 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
532 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
533 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
534 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
535 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
536 * Ada.Command_Line.Environment (a-colien.ads)::
537 * Ada.Command_Line.Remove (a-colire.ads)::
538 * Ada.Command_Line.Response_File (a-clrefi.ads)::
539 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
540 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
541 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
542 * Ada.Exceptions.Traceback (a-exctra.ads)::
543 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
544 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
545 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
546 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
547 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
548 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
549 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
550 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
551 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
552 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
553 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
554 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
555 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
556 * GNAT.Altivec (g-altive.ads)::
557 * GNAT.Altivec.Conversions (g-altcon.ads)::
558 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
559 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
560 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
561 * GNAT.Array_Split (g-arrspl.ads)::
562 * GNAT.AWK (g-awk.ads)::
563 * GNAT.Bounded_Buffers (g-boubuf.ads)::
564 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
565 * GNAT.Bubble_Sort (g-bubsor.ads)::
566 * GNAT.Bubble_Sort_A (g-busora.ads)::
567 * GNAT.Bubble_Sort_G (g-busorg.ads)::
568 * GNAT.Byte_Order_Mark (g-byorma.ads)::
569 * GNAT.Byte_Swapping (g-bytswa.ads)::
570 * GNAT.Calendar (g-calend.ads)::
571 * GNAT.Calendar.Time_IO (g-catiio.ads)::
572 * GNAT.Case_Util (g-casuti.ads)::
573 * GNAT.CGI (g-cgi.ads)::
574 * GNAT.CGI.Cookie (g-cgicoo.ads)::
575 * GNAT.CGI.Debug (g-cgideb.ads)::
576 * GNAT.Command_Line (g-comlin.ads)::
577 * GNAT.Compiler_Version (g-comver.ads)::
578 * GNAT.Ctrl_C (g-ctrl_c.ads)::
579 * GNAT.CRC32 (g-crc32.ads)::
580 * GNAT.Current_Exception (g-curexc.ads)::
581 * GNAT.Debug_Pools (g-debpoo.ads)::
582 * GNAT.Debug_Utilities (g-debuti.ads)::
583 * GNAT.Decode_String (g-decstr.ads)::
584 * GNAT.Decode_UTF8_String (g-deutst.ads)::
585 * GNAT.Directory_Operations (g-dirope.ads)::
586 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
587 * GNAT.Dynamic_HTables (g-dynhta.ads)::
588 * GNAT.Dynamic_Tables (g-dyntab.ads)::
589 * GNAT.Encode_String (g-encstr.ads)::
590 * GNAT.Encode_UTF8_String (g-enutst.ads)::
591 * GNAT.Exception_Actions (g-excact.ads)::
592 * GNAT.Exception_Traces (g-exctra.ads)::
593 * GNAT.Exceptions (g-except.ads)::
594 * GNAT.Expect (g-expect.ads)::
595 * GNAT.Expect.TTY (g-exptty.ads)::
596 * GNAT.Float_Control (g-flocon.ads)::
597 * GNAT.Formatted_String (g-forstr.ads)::
598 * GNAT.Heap_Sort (g-heasor.ads)::
599 * GNAT.Heap_Sort_A (g-hesora.ads)::
600 * GNAT.Heap_Sort_G (g-hesorg.ads)::
601 * GNAT.HTable (g-htable.ads)::
602 * GNAT.IO (g-io.ads)::
603 * GNAT.IO_Aux (g-io_aux.ads)::
604 * GNAT.Lock_Files (g-locfil.ads)::
605 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
606 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
607 * GNAT.MD5 (g-md5.ads)::
608 * GNAT.Memory_Dump (g-memdum.ads)::
609 * GNAT.Most_Recent_Exception (g-moreex.ads)::
610 * GNAT.OS_Lib (g-os_lib.ads)::
611 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
612 * GNAT.Random_Numbers (g-rannum.ads)::
613 * GNAT.Regexp (g-regexp.ads)::
614 * GNAT.Registry (g-regist.ads)::
615 * GNAT.Regpat (g-regpat.ads)::
616 * GNAT.Rewrite_Data (g-rewdat.ads)::
617 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
618 * GNAT.Semaphores (g-semaph.ads)::
619 * GNAT.Serial_Communications (g-sercom.ads)::
620 * GNAT.SHA1 (g-sha1.ads)::
621 * GNAT.SHA224 (g-sha224.ads)::
622 * GNAT.SHA256 (g-sha256.ads)::
623 * GNAT.SHA384 (g-sha384.ads)::
624 * GNAT.SHA512 (g-sha512.ads)::
625 * GNAT.Signals (g-signal.ads)::
626 * GNAT.Sockets (g-socket.ads)::
627 * GNAT.Source_Info (g-souinf.ads)::
628 * GNAT.Spelling_Checker (g-speche.ads)::
629 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
630 * GNAT.Spitbol.Patterns (g-spipat.ads)::
631 * GNAT.Spitbol (g-spitbo.ads)::
632 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
633 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
634 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
635 * GNAT.SSE (g-sse.ads)::
636 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
637 * GNAT.Strings (g-string.ads)::
638 * GNAT.String_Split (g-strspl.ads)::
639 * GNAT.Table (g-table.ads)::
640 * GNAT.Task_Lock (g-tasloc.ads)::
641 * GNAT.Threads (g-thread.ads)::
642 * GNAT.Time_Stamp (g-timsta.ads)::
643 * GNAT.Traceback (g-traceb.ads)::
644 * GNAT.Traceback.Symbolic (g-trasym.ads)::
645 * GNAT.UTF_32 (g-utf_32.ads)::
646 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
647 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
648 * GNAT.Wide_String_Split (g-wistsp.ads)::
649 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
650 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
651 * Interfaces.C.Extensions (i-cexten.ads)::
652 * Interfaces.C.Streams (i-cstrea.ads)::
653 * Interfaces.Packed_Decimal (i-pacdec.ads)::
654 * Interfaces.VxWorks (i-vxwork.ads)::
655 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
656 * System.Address_Image (s-addima.ads)::
657 * System.Assertions (s-assert.ads)::
658 * System.Memory (s-memory.ads)::
659 * System.Multiprocessors (s-multip.ads)::
660 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
661 * System.Partition_Interface (s-parint.ads)::
662 * System.Pool_Global (s-pooglo.ads)::
663 * System.Pool_Local (s-pooloc.ads)::
664 * System.Restrictions (s-restri.ads)::
665 * System.Rident (s-rident.ads)::
666 * System.Strings.Stream_Ops (s-ststop.ads)::
667 * System.Unsigned_Types (s-unstyp.ads)::
668 * System.Wch_Cnv (s-wchcnv.ads)::
669 * System.Wch_Con (s-wchcon.ads)::
670
671 Text_IO
672
673 * Text_IO Stream Pointer Positioning::
674 * Text_IO Reading and Writing Non-Regular Files::
675 * Get_Immediate::
676 * Treating Text_IO Files as Streams::
677 * Text_IO Extensions::
678 * Text_IO Facilities for Unbounded Strings::
679
680 Wide_Text_IO
681
682 * Wide_Text_IO Stream Pointer Positioning::
683 * Wide_Text_IO Reading and Writing Non-Regular Files::
684
685 Wide_Wide_Text_IO
686
687 * Wide_Wide_Text_IO Stream Pointer Positioning::
688 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
689
690 Interfacing to Other Languages
691
692 * Interfacing to C::
693 * Interfacing to C++::
694 * Interfacing to COBOL::
695 * Interfacing to Fortran::
696 * Interfacing to non-GNAT Ada code::
697
698 Specialized Needs Annexes
699
700 Implementation of Specific Ada Features
701 * Machine Code Insertions::
702 * GNAT Implementation of Tasking::
703 * GNAT Implementation of Shared Passive Packages::
704 * Code Generation for Array Aggregates::
705 * The Size of Discriminated Records with Default Discriminants::
706 * Strict Conformance to the Ada Reference Manual::
707
708 Implementation of Ada 2012 Features
709
710 Obsolescent Features
711
712 GNU Free Documentation License
713
714 Index
715 @end detailmenu
716 @end menu
717
718 @end ifnottex
719
720 @node About This Guide
721 @unnumbered About This Guide
722
723 @noindent
724 This manual contains useful information in writing programs using the
725 @value{EDITION} compiler. It includes information on implementation dependent
726 characteristics of @value{EDITION}, including all the information required by
727 Annex M of the Ada language standard.
728
729 @value{EDITION} implements Ada 95, Ada 2005 and Ada 2012, and it may also be
730 invoked in Ada 83 compatibility mode.
731 By default, @value{EDITION} assumes Ada 2012,
732 but you can override with a compiler switch
733 to explicitly specify the language version.
734 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
735 @value{EDITION} User's Guide}, for details on these switches.)
736 Throughout this manual, references to ``Ada'' without a year suffix
737 apply to all the Ada versions of the language.
738
739 Ada is designed to be highly portable.
740 In general, a program will have the same effect even when compiled by
741 different compilers on different platforms.
742 However, since Ada is designed to be used in a
743 wide variety of applications, it also contains a number of system
744 dependent features to be used in interfacing to the external world.
745 @cindex Implementation-dependent features
746 @cindex Portability
747
748 Note: Any program that makes use of implementation-dependent features
749 may be non-portable. You should follow good programming practice and
750 isolate and clearly document any sections of your program that make use
751 of these features in a non-portable manner.
752
753 @ifset PROEDITION
754 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
755 ``GNAT'' in the remainder of this document.
756 @end ifset
757
758 @menu
759 * What This Reference Manual Contains::
760 * Conventions::
761 * Related Information::
762 @end menu
763
764 @node What This Reference Manual Contains
765 @unnumberedsec What This Reference Manual Contains
766
767 @noindent
768 This reference manual contains the following chapters:
769
770 @itemize @bullet
771 @item
772 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
773 pragmas, which can be used to extend and enhance the functionality of the
774 compiler.
775
776 @item
777 @ref{Implementation Defined Attributes}, lists GNAT
778 implementation-dependent attributes, which can be used to extend and
779 enhance the functionality of the compiler.
780
781 @item
782 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
783 implementation-dependent restrictions, which can be used to extend and
784 enhance the functionality of the compiler.
785
786 @item
787 @ref{Implementation Advice}, provides information on generally
788 desirable behavior which are not requirements that all compilers must
789 follow since it cannot be provided on all systems, or which may be
790 undesirable on some systems.
791
792 @item
793 @ref{Implementation Defined Characteristics}, provides a guide to
794 minimizing implementation dependent features.
795
796 @item
797 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
798 implemented by GNAT, and how they can be imported into user
799 application programs.
800
801 @item
802 @ref{Representation Clauses and Pragmas}, describes in detail the
803 way that GNAT represents data, and in particular the exact set
804 of representation clauses and pragmas that is accepted.
805
806 @item
807 @ref{Standard Library Routines}, provides a listing of packages and a
808 brief description of the functionality that is provided by Ada's
809 extensive set of standard library routines as implemented by GNAT@.
810
811 @item
812 @ref{The Implementation of Standard I/O}, details how the GNAT
813 implementation of the input-output facilities.
814
815 @item
816 @ref{The GNAT Library}, is a catalog of packages that complement
817 the Ada predefined library.
818
819 @item
820 @ref{Interfacing to Other Languages}, describes how programs
821 written in Ada using GNAT can be interfaced to other programming
822 languages.
823
824 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
825 of the specialized needs annexes.
826
827 @item
828 @ref{Implementation of Specific Ada Features}, discusses issues related
829 to GNAT's implementation of machine code insertions, tasking, and several
830 other features.
831
832 @item
833 @ref{Implementation of Ada 2012 Features}, describes the status of the
834 GNAT implementation of the Ada 2012 language standard.
835
836 @item
837 @ref{Obsolescent Features} documents implementation dependent features,
838 including pragmas and attributes, which are considered obsolescent, since
839 there are other preferred ways of achieving the same results. These
840 obsolescent forms are retained for backwards compatibility.
841
842 @end itemize
843
844 @cindex Ada 95 Language Reference Manual
845 @cindex Ada 2005 Language Reference Manual
846 @noindent
847 This reference manual assumes a basic familiarity with the Ada 95 language, as
848 described in the International Standard ANSI/ISO/IEC-8652:1995,
849 January 1995.
850 It does not require knowledge of the new features introduced by Ada 2005,
851 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
852 and Amendment 1).
853 Both reference manuals are included in the GNAT documentation
854 package.
855
856 @node Conventions
857 @unnumberedsec Conventions
858 @cindex Conventions, typographical
859 @cindex Typographical conventions
860
861 @noindent
862 Following are examples of the typographical and graphic conventions used
863 in this guide:
864
865 @itemize @bullet
866 @item
867 @code{Functions}, @code{utility program names}, @code{standard names},
868 and @code{classes}.
869
870 @item
871 @code{Option flags}
872
873 @item
874 @file{File names}, @samp{button names}, and @samp{field names}.
875
876 @item
877 @code{Variables}, @env{environment variables}, and @var{metasyntactic
878 variables}.
879
880 @item
881 @emph{Emphasis}.
882
883 @item
884 [optional information or parameters]
885
886 @item
887 Examples are described by text
888 @smallexample
889 and then shown this way.
890 @end smallexample
891 @end itemize
892
893 @noindent
894 Commands that are entered by the user are preceded in this manual by the
895 characters @samp{$ } (dollar sign followed by space). If your system uses this
896 sequence as a prompt, then the commands will appear exactly as you see them
897 in the manual. If your system uses some other prompt, then the command will
898 appear with the @samp{$} replaced by whatever prompt character you are using.
899
900 @node Related Information
901 @unnumberedsec Related Information
902 @noindent
903 See the following documents for further information on GNAT:
904
905 @itemize @bullet
906 @item
907 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
908 @value{EDITION} User's Guide}, which provides information on how to use the
909 GNAT compiler system.
910
911 @item
912 @cite{Ada 95 Reference Manual}, which contains all reference
913 material for the Ada 95 programming language.
914
915 @item
916 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
917 of the Ada 95 standard. The annotations describe
918 detailed aspects of the design decision, and in particular contain useful
919 sections on Ada 83 compatibility.
920
921 @item
922 @cite{Ada 2005 Reference Manual}, which contains all reference
923 material for the Ada 2005 programming language.
924
925 @item
926 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
927 of the Ada 2005 standard. The annotations describe
928 detailed aspects of the design decision, and in particular contain useful
929 sections on Ada 83 and Ada 95 compatibility.
930
931 @item
932 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
933 which contains specific information on compatibility between GNAT and
934 DEC Ada 83 systems.
935
936 @item
937 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
938 describes in detail the pragmas and attributes provided by the DEC Ada 83
939 compiler system.
940
941 @end itemize
942
943 @node Implementation Defined Pragmas
944 @chapter Implementation Defined Pragmas
945
946 @noindent
947 Ada defines a set of pragmas that can be used to supply additional
948 information to the compiler. These language defined pragmas are
949 implemented in GNAT and work as described in the Ada Reference Manual.
950
951 In addition, Ada allows implementations to define additional pragmas
952 whose meaning is defined by the implementation. GNAT provides a number
953 of these implementation-defined pragmas, which can be used to extend
954 and enhance the functionality of the compiler. This section of the GNAT
955 Reference Manual describes these additional pragmas.
956
957 Note that any program using these pragmas might not be portable to other
958 compilers (although GNAT implements this set of pragmas on all
959 platforms). Therefore if portability to other compilers is an important
960 consideration, the use of these pragmas should be minimized.
961
962 @menu
963 * Pragma Abort_Defer::
964 * Pragma Abstract_State::
965 * Pragma Ada_83::
966 * Pragma Ada_95::
967 * Pragma Ada_05::
968 * Pragma Ada_2005::
969 * Pragma Ada_12::
970 * Pragma Ada_2012::
971 * Pragma Allow_Integer_Address::
972 * Pragma Annotate::
973 * Pragma Assert::
974 * Pragma Assert_And_Cut::
975 * Pragma Assertion_Policy::
976 * Pragma Assume::
977 * Pragma Assume_No_Invalid_Values::
978 * Pragma AST_Entry::
979 * Pragma Async_Readers::
980 * Pragma Async_Writers::
981 * Pragma Attribute_Definition::
982 * Pragma C_Pass_By_Copy::
983 * Pragma Check::
984 * Pragma Check_Float_Overflow::
985 * Pragma Check_Name::
986 * Pragma Check_Policy::
987 * Pragma CIL_Constructor::
988 * Pragma Comment::
989 * Pragma Common_Object::
990 * Pragma Compile_Time_Error::
991 * Pragma Compile_Time_Warning::
992 * Pragma Compiler_Unit::
993 * Pragma Compiler_Unit_Warning::
994 * Pragma Complete_Representation::
995 * Pragma Complex_Representation::
996 * Pragma Component_Alignment::
997 * Pragma Contract_Cases::
998 * Pragma Convention_Identifier::
999 * Pragma CPP_Class::
1000 * Pragma CPP_Constructor::
1001 * Pragma CPP_Virtual::
1002 * Pragma CPP_Vtable::
1003 * Pragma CPU::
1004 * Pragma Debug::
1005 * Pragma Debug_Policy::
1006 * Pragma Default_Scalar_Storage_Order::
1007 * Pragma Default_Storage_Pool::
1008 * Pragma Depends::
1009 * Pragma Detect_Blocking::
1010 * Pragma Disable_Atomic_Synchronization::
1011 * Pragma Dispatching_Domain::
1012 * Pragma Effective_Reads::
1013 * Pragma Effective_Writes::
1014 * Pragma Elaboration_Checks::
1015 * Pragma Eliminate::
1016 * Pragma Enable_Atomic_Synchronization::
1017 * Pragma Export_Exception::
1018 * Pragma Export_Function::
1019 * Pragma Export_Object::
1020 * Pragma Export_Procedure::
1021 * Pragma Export_Value::
1022 * Pragma Export_Valued_Procedure::
1023 * Pragma Extend_System::
1024 * Pragma Extensions_Allowed::
1025 * Pragma External::
1026 * Pragma External_Name_Casing::
1027 * Pragma Fast_Math::
1028 * Pragma Favor_Top_Level::
1029 * Pragma Finalize_Storage_Only::
1030 * Pragma Float_Representation::
1031 * Pragma Global::
1032 * Pragma Ident::
1033 * Pragma Implementation_Defined::
1034 * Pragma Implemented::
1035 * Pragma Implicit_Packing::
1036 * Pragma Import_Exception::
1037 * Pragma Import_Function::
1038 * Pragma Import_Object::
1039 * Pragma Import_Procedure::
1040 * Pragma Import_Valued_Procedure::
1041 * Pragma Independent::
1042 * Pragma Independent_Components::
1043 * Pragma Initial_Condition::
1044 * Pragma Initialize_Scalars::
1045 * Pragma Initializes::
1046 * Pragma Inline_Always::
1047 * Pragma Inline_Generic::
1048 * Pragma Interface::
1049 * Pragma Interface_Name::
1050 * Pragma Interrupt_Handler::
1051 * Pragma Interrupt_State::
1052 * Pragma Invariant::
1053 * Pragma Java_Constructor::
1054 * Pragma Java_Interface::
1055 * Pragma Keep_Names::
1056 * Pragma License::
1057 * Pragma Link_With::
1058 * Pragma Linker_Alias::
1059 * Pragma Linker_Constructor::
1060 * Pragma Linker_Destructor::
1061 * Pragma Linker_Section::
1062 * Pragma Lock_Free::
1063 * Pragma Long_Float::
1064 * Pragma Loop_Invariant::
1065 * Pragma Loop_Optimize::
1066 * Pragma Loop_Variant::
1067 * Pragma Machine_Attribute::
1068 * Pragma Main::
1069 * Pragma Main_Storage::
1070 * Pragma No_Body::
1071 * Pragma No_Inline::
1072 * Pragma No_Return::
1073 * Pragma No_Run_Time::
1074 * Pragma No_Strict_Aliasing::
1075 * Pragma Normalize_Scalars::
1076 * Pragma Obsolescent::
1077 * Pragma Optimize_Alignment::
1078 * Pragma Ordered::
1079 * Pragma Overflow_Mode::
1080 * Pragma Overriding_Renamings::
1081 * Pragma Partition_Elaboration_Policy::
1082 * Pragma Part_Of::
1083 * Pragma Passive::
1084 * Pragma Persistent_BSS::
1085 * Pragma Polling::
1086 * Pragma Post::
1087 * Pragma Postcondition::
1088 * Pragma Post_Class::
1089 * Pragma Pre::
1090 * Pragma Precondition::
1091 * Pragma Predicate::
1092 * Pragma Preelaborable_Initialization::
1093 * Pragma Pre_Class::
1094 * Pragma Priority_Specific_Dispatching::
1095 * Pragma Profile::
1096 * Pragma Profile_Warnings::
1097 * Pragma Propagate_Exceptions::
1098 * Pragma Provide_Shift_Operators::
1099 * Pragma Psect_Object::
1100 * Pragma Pure_Function::
1101 * Pragma Rational::
1102 * Pragma Ravenscar::
1103 * Pragma Refined_Depends::
1104 * Pragma Refined_Global::
1105 * Pragma Refined_Post::
1106 * Pragma Refined_State::
1107 * Pragma Relative_Deadline::
1108 * Pragma Remote_Access_Type::
1109 * Pragma Restricted_Run_Time::
1110 * Pragma Restriction_Warnings::
1111 * Pragma Reviewable::
1112 * Pragma Share_Generic::
1113 * Pragma Shared::
1114 * Pragma Short_Circuit_And_Or::
1115 * Pragma Short_Descriptors::
1116 * Pragma Simple_Storage_Pool_Type::
1117 * Pragma Source_File_Name::
1118 * Pragma Source_File_Name_Project::
1119 * Pragma Source_Reference::
1120 * Pragma SPARK_Mode::
1121 * Pragma Static_Elaboration_Desired::
1122 * Pragma Stream_Convert::
1123 * Pragma Style_Checks::
1124 * Pragma Subtitle::
1125 * Pragma Suppress::
1126 * Pragma Suppress_All::
1127 * Pragma Suppress_Debug_Info::
1128 * Pragma Suppress_Exception_Locations::
1129 * Pragma Suppress_Initialization::
1130 * Pragma Task_Name::
1131 * Pragma Task_Storage::
1132 * Pragma Test_Case::
1133 * Pragma Thread_Local_Storage::
1134 * Pragma Time_Slice::
1135 * Pragma Title::
1136 * Pragma Type_Invariant::
1137 * Pragma Type_Invariant_Class::
1138 * Pragma Unchecked_Union::
1139 * Pragma Unevaluated_Use_Of_Old::
1140 * Pragma Unimplemented_Unit::
1141 * Pragma Universal_Aliasing ::
1142 * Pragma Universal_Data::
1143 * Pragma Unmodified::
1144 * Pragma Unreferenced::
1145 * Pragma Unreferenced_Objects::
1146 * Pragma Unreserve_All_Interrupts::
1147 * Pragma Unsuppress::
1148 * Pragma Use_VADS_Size::
1149 * Pragma Validity_Checks::
1150 * Pragma Volatile::
1151 * Pragma Warning_As_Error::
1152 * Pragma Warnings::
1153 * Pragma Weak_External::
1154 * Pragma Wide_Character_Encoding::
1155 @end menu
1156
1157 @node Pragma Abort_Defer
1158 @unnumberedsec Pragma Abort_Defer
1159 @findex Abort_Defer
1160 @cindex Deferring aborts
1161 @noindent
1162 Syntax:
1163 @smallexample
1164 pragma Abort_Defer;
1165 @end smallexample
1166
1167 @noindent
1168 This pragma must appear at the start of the statement sequence of a
1169 handled sequence of statements (right after the @code{begin}). It has
1170 the effect of deferring aborts for the sequence of statements (but not
1171 for the declarations or handlers, if any, associated with this statement
1172 sequence).
1173
1174 @node Pragma Abstract_State
1175 @unnumberedsec Pragma Abstract_State
1176 @findex Abstract_State
1177 @noindent
1178 For the description of this pragma, see SPARK 2014 Reference Manual,
1179 section 7.1.4.
1180
1181 @node Pragma Ada_83
1182 @unnumberedsec Pragma Ada_83
1183 @findex Ada_83
1184 @noindent
1185 Syntax:
1186 @smallexample @c ada
1187 pragma Ada_83;
1188 @end smallexample
1189
1190 @noindent
1191 A configuration pragma that establishes Ada 83 mode for the unit to
1192 which it applies, regardless of the mode set by the command line
1193 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1194 the syntax and semantics of Ada 83, as defined in the original Ada
1195 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1196 and Ada 2005 are not recognized, optional package bodies are allowed,
1197 and generics may name types with unknown discriminants without using
1198 the @code{(<>)} notation. In addition, some but not all of the additional
1199 restrictions of Ada 83 are enforced.
1200
1201 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1202 Ada 83 code to be compiled and adapted to GNAT with less effort.
1203 Secondly, it aids in keeping code backwards compatible with Ada 83.
1204 However, there is no guarantee that code that is processed correctly
1205 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1206 83 compiler, since GNAT does not enforce all the additional checks
1207 required by Ada 83.
1208
1209 @node Pragma Ada_95
1210 @unnumberedsec Pragma Ada_95
1211 @findex Ada_95
1212 @noindent
1213 Syntax:
1214 @smallexample @c ada
1215 pragma Ada_95;
1216 @end smallexample
1217
1218 @noindent
1219 A configuration pragma that establishes Ada 95 mode for the unit to which
1220 it applies, regardless of the mode set by the command line switches.
1221 This mode is set automatically for the @code{Ada} and @code{System}
1222 packages and their children, so you need not specify it in these
1223 contexts. This pragma is useful when writing a reusable component that
1224 itself uses Ada 95 features, but which is intended to be usable from
1225 either Ada 83 or Ada 95 programs.
1226
1227 @node Pragma Ada_05
1228 @unnumberedsec Pragma Ada_05
1229 @findex Ada_05
1230 @noindent
1231 Syntax:
1232 @smallexample @c ada
1233 pragma Ada_05;
1234 pragma Ada_05 (local_NAME);
1235 @end smallexample
1236
1237 @noindent
1238 A configuration pragma that establishes Ada 2005 mode for the unit to which
1239 it applies, regardless of the mode set by the command line switches.
1240 This pragma is useful when writing a reusable component that
1241 itself uses Ada 2005 features, but which is intended to be usable from
1242 either Ada 83 or Ada 95 programs.
1243
1244 The one argument form (which is not a configuration pragma)
1245 is used for managing the transition from
1246 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
1247 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
1248 mode will generate a warning. In addition, in Ada_83 or Ada_95
1249 mode, a preference rule is established which does not choose
1250 such an entity unless it is unambiguously specified. This avoids
1251 extra subprograms marked this way from generating ambiguities in
1252 otherwise legal pre-Ada_2005 programs. The one argument form is
1253 intended for exclusive use in the GNAT run-time library.
1254
1255 @node Pragma Ada_2005
1256 @unnumberedsec Pragma Ada_2005
1257 @findex Ada_2005
1258 @noindent
1259 Syntax:
1260 @smallexample @c ada
1261 pragma Ada_2005;
1262 @end smallexample
1263
1264 @noindent
1265 This configuration pragma is a synonym for pragma Ada_05 and has the
1266 same syntax and effect.
1267
1268 @node Pragma Ada_12
1269 @unnumberedsec Pragma Ada_12
1270 @findex Ada_12
1271 @noindent
1272 Syntax:
1273 @smallexample @c ada
1274 pragma Ada_12;
1275 pragma Ada_12 (local_NAME);
1276 @end smallexample
1277
1278 @noindent
1279 A configuration pragma that establishes Ada 2012 mode for the unit to which
1280 it applies, regardless of the mode set by the command line switches.
1281 This mode is set automatically for the @code{Ada} and @code{System}
1282 packages and their children, so you need not specify it in these
1283 contexts. This pragma is useful when writing a reusable component that
1284 itself uses Ada 2012 features, but which is intended to be usable from
1285 Ada 83, Ada 95, or Ada 2005 programs.
1286
1287 The one argument form, which is not a configuration pragma,
1288 is used for managing the transition from Ada
1289 2005 to Ada 2012 in the run-time library. If an entity is marked
1290 as Ada_201 only, then referencing the entity in any pre-Ada_2012
1291 mode will generate a warning. In addition, in any pre-Ada_2012
1292 mode, a preference rule is established which does not choose
1293 such an entity unless it is unambiguously specified. This avoids
1294 extra subprograms marked this way from generating ambiguities in
1295 otherwise legal pre-Ada_2012 programs. The one argument form is
1296 intended for exclusive use in the GNAT run-time library.
1297
1298 @node Pragma Ada_2012
1299 @unnumberedsec Pragma Ada_2012
1300 @findex Ada_2005
1301 @noindent
1302 Syntax:
1303 @smallexample @c ada
1304 pragma Ada_2012;
1305 @end smallexample
1306
1307 @noindent
1308 This configuration pragma is a synonym for pragma Ada_12 and has the
1309 same syntax and effect.
1310
1311 @node Pragma Allow_Integer_Address
1312 @unnumberedsec Pragma Allow_Integer_Address
1313 @findex Allow_Integer_Address
1314 @noindent
1315 Syntax:
1316 @smallexample @c ada
1317 pragma Allow_Integer_Address;
1318 @end smallexample
1319
1320 @noindent
1321 In almost all versions of GNAT, @code{System.Address} is a private
1322 type in accordance with the implementation advice in the RM. This
1323 means that integer values,
1324 in particular integer literals, are not allowed as address values.
1325 If the configuration pragma
1326 @code{Allow_Integer_Address} is given, then integer expressions may
1327 be used anywhere a value of type @code{System.Address} is required.
1328 The effect is to introduce an implicit unchecked conversion from the
1329 integer value to type @code{System.Address}. The reverse case of using
1330 an address where an integer type is required is handled analogously.
1331 The following example compiles without errors:
1332
1333 @smallexample @c ada
1334 pragma Allow_Integer_Address;
1335 with System; use System;
1336 package AddrAsInt is
1337 X : Integer;
1338 Y : Integer;
1339 for X'Address use 16#1240#;
1340 for Y use at 16#3230#;
1341 m : Address := 16#4000#;
1342 n : constant Address := 4000;
1343 p : constant Address := Address (X + Y);
1344 v : Integer := y'Address;
1345 w : constant Integer := Integer (Y'Address);
1346 type R is new integer;
1347 RR : R := 1000;
1348 Z : Integer;
1349 for Z'Address use RR;
1350 end AddrAsInt;
1351 @end smallexample
1352
1353 @noindent
1354 Note that pragma @code{Allow_Integer_Address} is ignored if
1355 @code{System.Address}
1356 is not a private type. In implementations of @code{GNAT} where
1357 System.Address is a visible integer type (notably the implementations
1358 for @code{OpenVMS}), this pragma serves no purpose but is ignored
1359 rather than rejected to allow common sets of sources to be used
1360 in the two situations.
1361
1362 @node Pragma Annotate
1363 @unnumberedsec Pragma Annotate
1364 @findex Annotate
1365 @noindent
1366 Syntax:
1367 @smallexample @c ada
1368 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}] [entity => local_NAME]);
1369
1370 ARG ::= NAME | EXPRESSION
1371 @end smallexample
1372
1373 @noindent
1374 This pragma is used to annotate programs. @var{identifier} identifies
1375 the type of annotation. GNAT verifies that it is an identifier, but does
1376 not otherwise analyze it. The second optional identifier is also left
1377 unanalyzed, and by convention is used to control the action of the tool to
1378 which the annotation is addressed. The remaining @var{arg} arguments
1379 can be either string literals or more generally expressions.
1380 String literals are assumed to be either of type
1381 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1382 depending on the character literals they contain.
1383 All other kinds of arguments are analyzed as expressions, and must be
1384 unambiguous. The last argument if present must have the identifier
1385 @code{Entity} and GNAT verifies that a local name is given.
1386
1387 The analyzed pragma is retained in the tree, but not otherwise processed
1388 by any part of the GNAT compiler, except to generate corresponding note
1389 lines in the generated ALI file. For the format of these note lines, see
1390 the compiler source file lib-writ.ads. This pragma is intended for use by
1391 external tools, including ASIS@. The use of pragma Annotate does not
1392 affect the compilation process in any way. This pragma may be used as
1393 a configuration pragma.
1394
1395 @node Pragma Assert
1396 @unnumberedsec Pragma Assert
1397 @findex Assert
1398 @noindent
1399 Syntax:
1400 @smallexample @c ada
1401 pragma Assert (
1402 boolean_EXPRESSION
1403 [, string_EXPRESSION]);
1404 @end smallexample
1405
1406 @noindent
1407 The effect of this pragma depends on whether the corresponding command
1408 line switch is set to activate assertions. The pragma expands into code
1409 equivalent to the following:
1410
1411 @smallexample @c ada
1412 if assertions-enabled then
1413 if not boolean_EXPRESSION then
1414 System.Assertions.Raise_Assert_Failure
1415 (string_EXPRESSION);
1416 end if;
1417 end if;
1418 @end smallexample
1419
1420 @noindent
1421 The string argument, if given, is the message that will be associated
1422 with the exception occurrence if the exception is raised. If no second
1423 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1424 where @var{file} is the name of the source file containing the assert,
1425 and @var{nnn} is the line number of the assert. A pragma is not a
1426 statement, so if a statement sequence contains nothing but a pragma
1427 assert, then a null statement is required in addition, as in:
1428
1429 @smallexample @c ada
1430 @dots{}
1431 if J > 3 then
1432 pragma Assert (K > 3, "Bad value for K");
1433 null;
1434 end if;
1435 @end smallexample
1436
1437 @noindent
1438 Note that, as with the @code{if} statement to which it is equivalent, the
1439 type of the expression is either @code{Standard.Boolean}, or any type derived
1440 from this standard type.
1441
1442 Assert checks can be either checked or ignored. By default they are ignored.
1443 They will be checked if either the command line switch @option{-gnata} is
1444 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1445 to enable @code{Assert_Checks}.
1446
1447 If assertions are ignored, then there
1448 is no run-time effect (and in particular, any side effects from the
1449 expression will not occur at run time). (The expression is still
1450 analyzed at compile time, and may cause types to be frozen if they are
1451 mentioned here for the first time).
1452
1453 If assertions are checked, then the given expression is tested, and if
1454 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1455 which results in the raising of @code{Assert_Failure} with the given message.
1456
1457 You should generally avoid side effects in the expression arguments of
1458 this pragma, because these side effects will turn on and off with the
1459 setting of the assertions mode, resulting in assertions that have an
1460 effect on the program. However, the expressions are analyzed for
1461 semantic correctness whether or not assertions are enabled, so turning
1462 assertions on and off cannot affect the legality of a program.
1463
1464 Note that the implementation defined policy @code{DISABLE}, given in a
1465 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1466
1467 Note: this is a standard language-defined pragma in versions
1468 of Ada from 2005 on. In GNAT, it is implemented in all versions
1469 of Ada, and the DISABLE policy is an implementation-defined
1470 addition.
1471
1472 @node Pragma Assert_And_Cut
1473 @unnumberedsec Pragma Assert_And_Cut
1474 @findex Assert_And_Cut
1475 @noindent
1476 Syntax:
1477 @smallexample @c ada
1478 pragma Assert_And_Cut (
1479 boolean_EXPRESSION
1480 [, string_EXPRESSION]);
1481 @end smallexample
1482
1483 @noindent
1484 The effect of this pragma is identical to that of pragma @code{Assert},
1485 except that in an @code{Assertion_Policy} pragma, the identifier
1486 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1487 (or disabled).
1488
1489 The intention is that this be used within a subprogram when the
1490 given test expresion sums up all the work done so far in the
1491 subprogram, so that the rest of the subprogram can be verified
1492 (informally or formally) using only the entry preconditions,
1493 and the expression in this pragma. This allows dividing up
1494 a subprogram into sections for the purposes of testing or
1495 formal verification. The pragma also serves as useful
1496 documentation.
1497
1498 @node Pragma Assertion_Policy
1499 @unnumberedsec Pragma Assertion_Policy
1500 @findex Assertion_Policy
1501 @noindent
1502 Syntax:
1503 @smallexample @c ada
1504 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1505
1506 pragma Assertion_Policy (
1507 ASSERTION_KIND => POLICY_IDENTIFIER
1508 @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1509
1510 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1511
1512 RM_ASSERTION_KIND ::= Assert |
1513 Static_Predicate |
1514 Dynamic_Predicate |
1515 Pre |
1516 Pre'Class |
1517 Post |
1518 Post'Class |
1519 Type_Invariant |
1520 Type_Invariant'Class
1521
1522 ID_ASSERTION_KIND ::= Assertions |
1523 Assert_And_Cut |
1524 Assume |
1525 Contract_Cases |
1526 Debug |
1527 Invariant |
1528 Invariant'Class |
1529 Loop_Invariant |
1530 Loop_Variant |
1531 Postcondition |
1532 Precondition |
1533 Predicate |
1534 Refined_Post |
1535 Statement_Assertions
1536
1537 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1538 @end smallexample
1539
1540 @noindent
1541 This is a standard Ada 2012 pragma that is available as an
1542 implementation-defined pragma in earlier versions of Ada.
1543 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1544 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1545 are implementation defined additions recognized by the GNAT compiler.
1546
1547 The pragma applies in both cases to pragmas and aspects with matching
1548 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1549 applies to both the @code{Precondition} pragma
1550 and the aspect @code{Precondition}. Note that the identifiers for
1551 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
1552 Pre_Class and Post_Class), since these pragmas are intended to be
1553 identical to the corresponding aspects).
1554
1555 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1556 the corresponding pragma or aspect is activated.
1557 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1558 the corresponding pragma or aspect is deactivated.
1559 This pragma overrides the effect of the @option{-gnata} switch on the
1560 command line.
1561
1562 The implementation defined policy @code{DISABLE} is like
1563 @code{IGNORE} except that it completely disables semantic
1564 checking of the corresponding pragma or aspect. This is
1565 useful when the pragma or aspect argument references subprograms
1566 in a with'ed package which is replaced by a dummy package
1567 for the final build.
1568
1569 The implementation defined assertion kind @code{Assertions} applies to all
1570 assertion kinds. The form with no assertion kind given implies this
1571 choice, so it applies to all assertion kinds (RM defined, and
1572 implementation defined).
1573
1574 The implementation defined assertion kind @code{Statement_Assertions}
1575 applies to @code{Assert}, @code{Assert_And_Cut},
1576 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1577
1578 @node Pragma Assume
1579 @unnumberedsec Pragma Assume
1580 @findex Assume
1581 @noindent
1582 Syntax:
1583 @smallexample @c ada
1584 pragma Assume (
1585 boolean_EXPRESSION
1586 [, string_EXPRESSION]);
1587 @end smallexample
1588
1589 @noindent
1590 The effect of this pragma is identical to that of pragma @code{Assert},
1591 except that in an @code{Assertion_Policy} pragma, the identifier
1592 @code{Assume} is used to control whether it is ignored or checked
1593 (or disabled).
1594
1595 The intention is that this be used for assumptions about the
1596 external environment. So you cannot expect to verify formally
1597 or informally that the condition is met, this must be
1598 established by examining things outside the program itself.
1599 For example, we may have code that depends on the size of
1600 @code{Long_Long_Integer} being at least 64. So we could write:
1601
1602 @smallexample @c ada
1603 pragma Assume (Long_Long_Integer'Size >= 64);
1604 @end smallexample
1605
1606 @noindent
1607 This assumption cannot be proved from the program itself,
1608 but it acts as a useful run-time check that the assumption
1609 is met, and documents the need to ensure that it is met by
1610 reference to information outside the program.
1611
1612 @node Pragma Assume_No_Invalid_Values
1613 @unnumberedsec Pragma Assume_No_Invalid_Values
1614 @findex Assume_No_Invalid_Values
1615 @cindex Invalid representations
1616 @cindex Invalid values
1617 @noindent
1618 Syntax:
1619 @smallexample @c ada
1620 pragma Assume_No_Invalid_Values (On | Off);
1621 @end smallexample
1622
1623 @noindent
1624 This is a configuration pragma that controls the assumptions made by the
1625 compiler about the occurrence of invalid representations (invalid values)
1626 in the code.
1627
1628 The default behavior (corresponding to an Off argument for this pragma), is
1629 to assume that values may in general be invalid unless the compiler can
1630 prove they are valid. Consider the following example:
1631
1632 @smallexample @c ada
1633 V1 : Integer range 1 .. 10;
1634 V2 : Integer range 11 .. 20;
1635 ...
1636 for J in V2 .. V1 loop
1637 ...
1638 end loop;
1639 @end smallexample
1640
1641 @noindent
1642 if V1 and V2 have valid values, then the loop is known at compile
1643 time not to execute since the lower bound must be greater than the
1644 upper bound. However in default mode, no such assumption is made,
1645 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1646 is given, the compiler will assume that any occurrence of a variable
1647 other than in an explicit @code{'Valid} test always has a valid
1648 value, and the loop above will be optimized away.
1649
1650 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1651 you know your code is free of uninitialized variables and other
1652 possible sources of invalid representations, and may result in
1653 more efficient code. A program that accesses an invalid representation
1654 with this pragma in effect is erroneous, so no guarantees can be made
1655 about its behavior.
1656
1657 It is peculiar though permissible to use this pragma in conjunction
1658 with validity checking (-gnatVa). In such cases, accessing invalid
1659 values will generally give an exception, though formally the program
1660 is erroneous so there are no guarantees that this will always be the
1661 case, and it is recommended that these two options not be used together.
1662
1663 @node Pragma Async_Readers
1664 @unnumberedsec Pragma Async_Readers
1665 @findex Async_Readers
1666 @noindent
1667 For the description of this pragma, see SPARK 2014 Reference Manual,
1668 section 7.1.2.
1669
1670 @node Pragma Async_Writers
1671 @unnumberedsec Pragma Async_Writers
1672 @findex Async_Writers
1673 @noindent
1674 For the description of this pragma, see SPARK 2014 Reference Manual,
1675 section 7.1.2.
1676
1677 @node Pragma AST_Entry
1678 @unnumberedsec Pragma AST_Entry
1679 @cindex OpenVMS
1680 @findex AST_Entry
1681 @noindent
1682 Syntax:
1683 @smallexample @c ada
1684 pragma AST_Entry (entry_IDENTIFIER);
1685 @end smallexample
1686
1687 @noindent
1688 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1689 argument is the simple name of a single entry; at most one @code{AST_Entry}
1690 pragma is allowed for any given entry. This pragma must be used in
1691 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1692 the entry declaration and in the same task type specification or single task
1693 as the entry to which it applies. This pragma specifies that the given entry
1694 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1695 resulting from an OpenVMS system service call. The pragma does not affect
1696 normal use of the entry. For further details on this pragma, see the
1697 DEC Ada Language Reference Manual, section 9.12a.
1698
1699 @node Pragma Attribute_Definition
1700 @unnumberedsec Pragma Attribute_Definition
1701 @findex Attribute_Definition
1702 @noindent
1703 Syntax:
1704 @smallexample @c ada
1705 pragma Attribute_Definition
1706 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1707 [Entity =>] LOCAL_NAME,
1708 [Expression =>] EXPRESSION | NAME);
1709 @end smallexample
1710
1711 @noindent
1712 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1713 the attribute definition clause:
1714
1715 @smallexample @c ada
1716 for Entity'Attribute use Expression;
1717 @end smallexample
1718
1719 If @code{Attribute} is not a recognized attribute name, the pragma is
1720 ignored, and a warning is emitted. This allows source
1721 code to be written that takes advantage of some new attribute, while remaining
1722 compilable with earlier compilers.
1723
1724 @node Pragma C_Pass_By_Copy
1725 @unnumberedsec Pragma C_Pass_By_Copy
1726 @cindex Passing by copy
1727 @findex C_Pass_By_Copy
1728 @noindent
1729 Syntax:
1730 @smallexample @c ada
1731 pragma C_Pass_By_Copy
1732 ([Max_Size =>] static_integer_EXPRESSION);
1733 @end smallexample
1734
1735 @noindent
1736 Normally the default mechanism for passing C convention records to C
1737 convention subprograms is to pass them by reference, as suggested by RM
1738 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1739 this default, by requiring that record formal parameters be passed by
1740 copy if all of the following conditions are met:
1741
1742 @itemize @bullet
1743 @item
1744 The size of the record type does not exceed the value specified for
1745 @code{Max_Size}.
1746 @item
1747 The record type has @code{Convention C}.
1748 @item
1749 The formal parameter has this record type, and the subprogram has a
1750 foreign (non-Ada) convention.
1751 @end itemize
1752
1753 @noindent
1754 If these conditions are met the argument is passed by copy, i.e.@: in a
1755 manner consistent with what C expects if the corresponding formal in the
1756 C prototype is a struct (rather than a pointer to a struct).
1757
1758 You can also pass records by copy by specifying the convention
1759 @code{C_Pass_By_Copy} for the record type, or by using the extended
1760 @code{Import} and @code{Export} pragmas, which allow specification of
1761 passing mechanisms on a parameter by parameter basis.
1762
1763 @node Pragma Check
1764 @unnumberedsec Pragma Check
1765 @cindex Assertions
1766 @cindex Named assertions
1767 @findex Check
1768 @noindent
1769 Syntax:
1770 @smallexample @c ada
1771 pragma Check (
1772 [Name =>] CHECK_KIND,
1773 [Check =>] Boolean_EXPRESSION
1774 [, [Message =>] string_EXPRESSION] );
1775
1776 CHECK_KIND ::= IDENTIFIER |
1777 Pre'Class |
1778 Post'Class |
1779 Type_Invariant'Class |
1780 Invariant'Class
1781 @end smallexample
1782
1783 @noindent
1784 This pragma is similar to the predefined pragma @code{Assert} except that an
1785 extra identifier argument is present. In conjunction with pragma
1786 @code{Check_Policy}, this can be used to define groups of assertions that can
1787 be independently controlled. The identifier @code{Assertion} is special, it
1788 refers to the normal set of pragma @code{Assert} statements.
1789
1790 Checks introduced by this pragma are normally deactivated by default. They can
1791 be activated either by the command line option @option{-gnata}, which turns on
1792 all checks, or individually controlled using pragma @code{Check_Policy}.
1793
1794 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
1795 permitted as check kinds, since this would cause confusion with the use
1796 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
1797 pragmas, where they are used to refer to sets of assertions.
1798
1799 @node Pragma Check_Float_Overflow
1800 @unnumberedsec Pragma Check_Float_Overflow
1801 @cindex Floating-point overflow
1802 @findex Check_Float_Overflow
1803 @noindent
1804 Syntax:
1805 @smallexample @c ada
1806 pragma Check_Float_Overflow;
1807 @end smallexample
1808
1809 @noindent
1810 In Ada, the predefined floating-point types (@code{Short_Float},
1811 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1812 defined to be @emph{unconstrained}. This means that even though each
1813 has a well-defined base range, an operation that delivers a result
1814 outside this base range is not required to raise an exception.
1815 This implementation permission accommodates the notion
1816 of infinities in IEEE floating-point, and corresponds to the
1817 efficient execution mode on most machines. GNAT will not raise
1818 overflow exceptions on these machines; instead it will generate
1819 infinities and NaN's as defined in the IEEE standard.
1820
1821 Generating infinities, although efficient, is not always desirable.
1822 Often the preferable approach is to check for overflow, even at the
1823 (perhaps considerable) expense of run-time performance.
1824 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1825 range constraints -- and indeed such a subtype
1826 can have the same base range as its base type. For example:
1827
1828 @smallexample @c ada
1829 subtype My_Float is Float range Float'Range;
1830 @end smallexample
1831
1832 @noindent
1833 Here @code{My_Float} has the same range as
1834 @code{Float} but is constrained, so operations on
1835 @code{My_Float} values will be checked for overflow
1836 against this range.
1837
1838 This style will achieve the desired goal, but
1839 it is often more convenient to be able to simply use
1840 the standard predefined floating-point types as long
1841 as overflow checking could be guaranteed.
1842 The @code{Check_Float_Overflow}
1843 configuration pragma achieves this effect. If a unit is compiled
1844 subject to this configuration pragma, then all operations
1845 on predefined floating-point types including operations on
1846 base types of these floating-point types will be treated as
1847 though those types were constrained, and overflow checks
1848 will be generated. The @code{Constraint_Error}
1849 exception is raised if the result is out of range.
1850
1851 This mode can also be set by use of the compiler
1852 switch @option{-gnateF}.
1853
1854 @node Pragma Check_Name
1855 @unnumberedsec Pragma Check_Name
1856 @cindex Defining check names
1857 @cindex Check names, defining
1858 @findex Check_Name
1859 @noindent
1860 Syntax:
1861 @smallexample @c ada
1862 pragma Check_Name (check_name_IDENTIFIER);
1863 @end smallexample
1864
1865 @noindent
1866 This is a configuration pragma that defines a new implementation
1867 defined check name (unless IDENTIFIER matches one of the predefined
1868 check names, in which case the pragma has no effect). Check names
1869 are global to a partition, so if two or more configuration pragmas
1870 are present in a partition mentioning the same name, only one new
1871 check name is introduced.
1872
1873 An implementation defined check name introduced with this pragma may
1874 be used in only three contexts: @code{pragma Suppress},
1875 @code{pragma Unsuppress},
1876 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1877 any of these three cases, the check name must be visible. A check
1878 name is visible if it is in the configuration pragmas applying to
1879 the current unit, or if it appears at the start of any unit that
1880 is part of the dependency set of the current unit (e.g., units that
1881 are mentioned in @code{with} clauses).
1882
1883 Check names introduced by this pragma are subject to control by compiler
1884 switches (in particular -gnatp) in the usual manner.
1885
1886 @node Pragma Check_Policy
1887 @unnumberedsec Pragma Check_Policy
1888 @cindex Controlling assertions
1889 @cindex Assertions, control
1890 @cindex Check pragma control
1891 @cindex Named assertions
1892 @findex Check
1893 @noindent
1894 Syntax:
1895 @smallexample @c ada
1896 pragma Check_Policy
1897 ([Name =>] CHECK_KIND,
1898 [Policy =>] POLICY_IDENTIFIER);
1899
1900 pragma Check_Policy (
1901 CHECK_KIND => POLICY_IDENTIFIER
1902 @{, CHECK_KIND => POLICY_IDENTIFIER@});
1903
1904 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1905
1906 CHECK_KIND ::= IDENTIFIER |
1907 Pre'Class |
1908 Post'Class |
1909 Type_Invariant'Class |
1910 Invariant'Class
1911
1912 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
1913 avoids confusion between the two possible syntax forms for this pragma.
1914
1915 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1916 @end smallexample
1917
1918 @noindent
1919 This pragma is used to set the checking policy for assertions (specified
1920 by aspects or pragmas), the @code{Debug} pragma, or additional checks
1921 to be checked using the @code{Check} pragma. It may appear either as
1922 a configuration pragma, or within a declarative part of package. In the
1923 latter case, it applies from the point where it appears to the end of
1924 the declarative region (like pragma @code{Suppress}).
1925
1926 The @code{Check_Policy} pragma is similar to the
1927 predefined @code{Assertion_Policy} pragma,
1928 and if the check kind corresponds to one of the assertion kinds that
1929 are allowed by @code{Assertion_Policy}, then the effect is identical.
1930
1931 If the first argument is Debug, then the policy applies to Debug pragmas,
1932 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
1933 @code{IGNORE}, and allowing them to execute with normal semantics if
1934 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
1935 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
1936 be totally ignored and not analyzed semantically.
1937
1938 Finally the first argument may be some other identifier than the above
1939 possibilities, in which case it controls a set of named assertions
1940 that can be checked using pragma @code{Check}. For example, if the pragma:
1941
1942 @smallexample @c ada
1943 pragma Check_Policy (Critical_Error, OFF);
1944 @end smallexample
1945
1946 @noindent
1947 is given, then subsequent @code{Check} pragmas whose first argument is also
1948 @code{Critical_Error} will be disabled.
1949
1950 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1951 to turn on corresponding checks. The default for a set of checks for which no
1952 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1953 @option{-gnata} is given, which turns on all checks by default.
1954
1955 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1956 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1957 compatibility with the standard @code{Assertion_Policy} pragma. The check
1958 policy setting @code{DISABLE} causes the second argument of a corresponding
1959 @code{Check} pragma to be completely ignored and not analyzed.
1960
1961 @node Pragma CIL_Constructor
1962 @unnumberedsec Pragma CIL_Constructor
1963 @findex CIL_Constructor
1964 @noindent
1965 Syntax:
1966
1967 @smallexample @c ada
1968 pragma CIL_Constructor ([Entity =>] function_LOCAL_NAME);
1969 @end smallexample
1970
1971 @noindent
1972 This pragma is used to assert that the specified Ada function should be
1973 mapped to the .NET constructor for some Ada tagged record type.
1974
1975 See section 4.1 of the
1976 @code{GNAT User's Guide: Supplement for the .NET Platform.}
1977 for related information.
1978
1979 @node Pragma Comment
1980 @unnumberedsec Pragma Comment
1981 @findex Comment
1982 @noindent
1983 Syntax:
1984
1985 @smallexample @c ada
1986 pragma Comment (static_string_EXPRESSION);
1987 @end smallexample
1988
1989 @noindent
1990 This is almost identical in effect to pragma @code{Ident}. It allows the
1991 placement of a comment into the object file and hence into the
1992 executable file if the operating system permits such usage. The
1993 difference is that @code{Comment}, unlike @code{Ident}, has
1994 no limitations on placement of the pragma (it can be placed
1995 anywhere in the main source unit), and if more than one pragma
1996 is used, all comments are retained.
1997
1998 @node Pragma Common_Object
1999 @unnumberedsec Pragma Common_Object
2000 @findex Common_Object
2001 @noindent
2002 Syntax:
2003
2004 @smallexample @c ada
2005 pragma Common_Object (
2006 [Internal =>] LOCAL_NAME
2007 [, [External =>] EXTERNAL_SYMBOL]
2008 [, [Size =>] EXTERNAL_SYMBOL] );
2009
2010 EXTERNAL_SYMBOL ::=
2011 IDENTIFIER
2012 | static_string_EXPRESSION
2013 @end smallexample
2014
2015 @noindent
2016 This pragma enables the shared use of variables stored in overlaid
2017 linker areas corresponding to the use of @code{COMMON}
2018 in Fortran. The single
2019 object @var{LOCAL_NAME} is assigned to the area designated by
2020 the @var{External} argument.
2021 You may define a record to correspond to a series
2022 of fields. The @var{Size} argument
2023 is syntax checked in GNAT, but otherwise ignored.
2024
2025 @code{Common_Object} is not supported on all platforms. If no
2026 support is available, then the code generator will issue a message
2027 indicating that the necessary attribute for implementation of this
2028 pragma is not available.
2029
2030 @node Pragma Compile_Time_Error
2031 @unnumberedsec Pragma Compile_Time_Error
2032 @findex Compile_Time_Error
2033 @noindent
2034 Syntax:
2035
2036 @smallexample @c ada
2037 pragma Compile_Time_Error
2038 (boolean_EXPRESSION, static_string_EXPRESSION);
2039 @end smallexample
2040
2041 @noindent
2042 This pragma can be used to generate additional compile time
2043 error messages. It
2044 is particularly useful in generics, where errors can be issued for
2045 specific problematic instantiations. The first parameter is a boolean
2046 expression. The pragma is effective only if the value of this expression
2047 is known at compile time, and has the value True. The set of expressions
2048 whose values are known at compile time includes all static boolean
2049 expressions, and also other values which the compiler can determine
2050 at compile time (e.g., the size of a record type set by an explicit
2051 size representation clause, or the value of a variable which was
2052 initialized to a constant and is known not to have been modified).
2053 If these conditions are met, an error message is generated using
2054 the value given as the second argument. This string value may contain
2055 embedded ASCII.LF characters to break the message into multiple lines.
2056
2057 @node Pragma Compile_Time_Warning
2058 @unnumberedsec Pragma Compile_Time_Warning
2059 @findex Compile_Time_Warning
2060 @noindent
2061 Syntax:
2062
2063 @smallexample @c ada
2064 pragma Compile_Time_Warning
2065 (boolean_EXPRESSION, static_string_EXPRESSION);
2066 @end smallexample
2067
2068 @noindent
2069 Same as pragma Compile_Time_Error, except a warning is issued instead
2070 of an error message. Note that if this pragma is used in a package that
2071 is with'ed by a client, the client will get the warning even though it
2072 is issued by a with'ed package (normally warnings in with'ed units are
2073 suppressed, but this is a special exception to that rule).
2074
2075 One typical use is within a generic where compile time known characteristics
2076 of formal parameters are tested, and warnings given appropriately. Another use
2077 with a first parameter of True is to warn a client about use of a package,
2078 for example that it is not fully implemented.
2079
2080 @node Pragma Compiler_Unit
2081 @unnumberedsec Pragma Compiler_Unit
2082 @findex Compiler_Unit
2083 @noindent
2084 Syntax:
2085
2086 @smallexample @c ada
2087 pragma Compiler_Unit;
2088 @end smallexample
2089
2090 @noindent
2091 This pragma is obsolete. It is equivalent to Compiler_Unit_Warning. It is
2092 retained so that old versions of the GNAT run-time that use this pragma can
2093 be compiled with newer versions of the compiler.
2094
2095 @node Pragma Compiler_Unit_Warning
2096 @unnumberedsec Pragma Compiler_Unit_Warning
2097 @findex Compiler_Unit_Warning
2098 @noindent
2099 Syntax:
2100
2101 @smallexample @c ada
2102 pragma Compiler_Unit_Warning;
2103 @end smallexample
2104
2105 @noindent
2106 This pragma is intended only for internal use in the GNAT run-time library.
2107 It indicates that the unit is used as part of the compiler build. The effect
2108 is to generate warnings for the use of constructs (for example, conditional
2109 expressions) that would cause trouble when bootstrapping using an older
2110 version of GNAT. For the exact list of restrictions, see the compiler sources
2111 and references to Check_Compiler_Unit.
2112
2113 @node Pragma Complete_Representation
2114 @unnumberedsec Pragma Complete_Representation
2115 @findex Complete_Representation
2116 @noindent
2117 Syntax:
2118
2119 @smallexample @c ada
2120 pragma Complete_Representation;
2121 @end smallexample
2122
2123 @noindent
2124 This pragma must appear immediately within a record representation
2125 clause. Typical placements are before the first component clause
2126 or after the last component clause. The effect is to give an error
2127 message if any component is missing a component clause. This pragma
2128 may be used to ensure that a record representation clause is
2129 complete, and that this invariant is maintained if fields are
2130 added to the record in the future.
2131
2132 @node Pragma Complex_Representation
2133 @unnumberedsec Pragma Complex_Representation
2134 @findex Complex_Representation
2135 @noindent
2136 Syntax:
2137
2138 @smallexample @c ada
2139 pragma Complex_Representation
2140 ([Entity =>] LOCAL_NAME);
2141 @end smallexample
2142
2143 @noindent
2144 The @var{Entity} argument must be the name of a record type which has
2145 two fields of the same floating-point type. The effect of this pragma is
2146 to force gcc to use the special internal complex representation form for
2147 this record, which may be more efficient. Note that this may result in
2148 the code for this type not conforming to standard ABI (application
2149 binary interface) requirements for the handling of record types. For
2150 example, in some environments, there is a requirement for passing
2151 records by pointer, and the use of this pragma may result in passing
2152 this type in floating-point registers.
2153
2154 @node Pragma Component_Alignment
2155 @unnumberedsec Pragma Component_Alignment
2156 @cindex Alignments of components
2157 @findex Component_Alignment
2158 @noindent
2159 Syntax:
2160
2161 @smallexample @c ada
2162 pragma Component_Alignment (
2163 [Form =>] ALIGNMENT_CHOICE
2164 [, [Name =>] type_LOCAL_NAME]);
2165
2166 ALIGNMENT_CHOICE ::=
2167 Component_Size
2168 | Component_Size_4
2169 | Storage_Unit
2170 | Default
2171 @end smallexample
2172
2173 @noindent
2174 Specifies the alignment of components in array or record types.
2175 The meaning of the @var{Form} argument is as follows:
2176
2177 @table @code
2178 @findex Component_Size
2179 @item Component_Size
2180 Aligns scalar components and subcomponents of the array or record type
2181 on boundaries appropriate to their inherent size (naturally
2182 aligned). For example, 1-byte components are aligned on byte boundaries,
2183 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2184 integer components are aligned on 4-byte boundaries and so on. These
2185 alignment rules correspond to the normal rules for C compilers on all
2186 machines except the VAX@.
2187
2188 @findex Component_Size_4
2189 @item Component_Size_4
2190 Naturally aligns components with a size of four or fewer
2191 bytes. Components that are larger than 4 bytes are placed on the next
2192 4-byte boundary.
2193
2194 @findex Storage_Unit
2195 @item Storage_Unit
2196 Specifies that array or record components are byte aligned, i.e.@:
2197 aligned on boundaries determined by the value of the constant
2198 @code{System.Storage_Unit}.
2199
2200 @cindex OpenVMS
2201 @item Default
2202 Specifies that array or record components are aligned on default
2203 boundaries, appropriate to the underlying hardware or operating system or
2204 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
2205 the @code{Storage_Unit} choice (byte alignment). For all other systems,
2206 the @code{Default} choice is the same as @code{Component_Size} (natural
2207 alignment).
2208 @end table
2209
2210 @noindent
2211 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
2212 refer to a local record or array type, and the specified alignment
2213 choice applies to the specified type. The use of
2214 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2215 @code{Component_Alignment} pragma to be ignored. The use of
2216 @code{Component_Alignment} together with a record representation clause
2217 is only effective for fields not specified by the representation clause.
2218
2219 If the @code{Name} parameter is absent, the pragma can be used as either
2220 a configuration pragma, in which case it applies to one or more units in
2221 accordance with the normal rules for configuration pragmas, or it can be
2222 used within a declarative part, in which case it applies to types that
2223 are declared within this declarative part, or within any nested scope
2224 within this declarative part. In either case it specifies the alignment
2225 to be applied to any record or array type which has otherwise standard
2226 representation.
2227
2228 If the alignment for a record or array type is not specified (using
2229 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2230 clause), the GNAT uses the default alignment as described previously.
2231
2232 @node Pragma Contract_Cases
2233 @unnumberedsec Pragma Contract_Cases
2234 @cindex Contract cases
2235 @findex Contract_Cases
2236 @noindent
2237 Syntax:
2238
2239 @smallexample @c ada
2240 pragma Contract_Cases (
2241 Condition => Consequence
2242 @{,Condition => Consequence@});
2243 @end smallexample
2244
2245 @noindent
2246 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2247 that can complement or replace the contract given by a precondition and a
2248 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2249 by testing and formal verification tools. The compiler checks its validity and,
2250 depending on the assertion policy at the point of declaration of the pragma,
2251 it may insert a check in the executable. For code generation, the contract
2252 cases
2253
2254 @smallexample @c ada
2255 pragma Contract_Cases (
2256 Cond1 => Pred1,
2257 Cond2 => Pred2);
2258 @end smallexample
2259
2260 @noindent
2261 are equivalent to
2262
2263 @smallexample @c ada
2264 C1 : constant Boolean := Cond1; -- evaluated at subprogram entry
2265 C2 : constant Boolean := Cond2; -- evaluated at subprogram entry
2266 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2267 pragma Postcondition (if C1 then Pred1);
2268 pragma Postcondition (if C2 then Pred2);
2269 @end smallexample
2270
2271 @noindent
2272 The precondition ensures that one and only one of the conditions is
2273 satisfied on entry to the subprogram.
2274 The postcondition ensures that for the condition that was True on entry,
2275 the corrresponding consequence is True on exit. Other consequence expressions
2276 are not evaluated.
2277
2278 A precondition @code{P} and postcondition @code{Q} can also be
2279 expressed as contract cases:
2280
2281 @smallexample @c ada
2282 pragma Contract_Cases (P => Q);
2283 @end smallexample
2284
2285 The placement and visibility rules for @code{Contract_Cases} pragmas are
2286 identical to those described for preconditions and postconditions.
2287
2288 The compiler checks that boolean expressions given in conditions and
2289 consequences are valid, where the rules for conditions are the same as
2290 the rule for an expression in @code{Precondition} and the rules for
2291 consequences are the same as the rule for an expression in
2292 @code{Postcondition}. In particular, attributes @code{'Old} and
2293 @code{'Result} can only be used within consequence expressions.
2294 The condition for the last contract case may be @code{others}, to denote
2295 any case not captured by the previous cases. The
2296 following is an example of use within a package spec:
2297
2298 @smallexample @c ada
2299 package Math_Functions is
2300 ...
2301 function Sqrt (Arg : Float) return Float;
2302 pragma Contract_Cases ((Arg in 0 .. 99) => Sqrt'Result < 10,
2303 Arg >= 100 => Sqrt'Result >= 10,
2304 others => Sqrt'Result = 0);
2305 ...
2306 end Math_Functions;
2307 @end smallexample
2308
2309 @noindent
2310 The meaning of contract cases is that only one case should apply at each
2311 call, as determined by the corresponding condition evaluating to True,
2312 and that the consequence for this case should hold when the subprogram
2313 returns.
2314
2315 @node Pragma Convention_Identifier
2316 @unnumberedsec Pragma Convention_Identifier
2317 @findex Convention_Identifier
2318 @cindex Conventions, synonyms
2319 @noindent
2320 Syntax:
2321
2322 @smallexample @c ada
2323 pragma Convention_Identifier (
2324 [Name =>] IDENTIFIER,
2325 [Convention =>] convention_IDENTIFIER);
2326 @end smallexample
2327
2328 @noindent
2329 This pragma provides a mechanism for supplying synonyms for existing
2330 convention identifiers. The @code{Name} identifier can subsequently
2331 be used as a synonym for the given convention in other pragmas (including
2332 for example pragma @code{Import} or another @code{Convention_Identifier}
2333 pragma). As an example of the use of this, suppose you had legacy code
2334 which used Fortran77 as the identifier for Fortran. Then the pragma:
2335
2336 @smallexample @c ada
2337 pragma Convention_Identifier (Fortran77, Fortran);
2338 @end smallexample
2339
2340 @noindent
2341 would allow the use of the convention identifier @code{Fortran77} in
2342 subsequent code, avoiding the need to modify the sources. As another
2343 example, you could use this to parameterize convention requirements
2344 according to systems. Suppose you needed to use @code{Stdcall} on
2345 windows systems, and @code{C} on some other system, then you could
2346 define a convention identifier @code{Library} and use a single
2347 @code{Convention_Identifier} pragma to specify which convention
2348 would be used system-wide.
2349
2350 @node Pragma CPP_Class
2351 @unnumberedsec Pragma CPP_Class
2352 @findex CPP_Class
2353 @cindex Interfacing with C++
2354 @noindent
2355 Syntax:
2356
2357 @smallexample @c ada
2358 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2359 @end smallexample
2360
2361 @noindent
2362 The argument denotes an entity in the current declarative region that is
2363 declared as a record type. It indicates that the type corresponds to an
2364 externally declared C++ class type, and is to be laid out the same way
2365 that C++ would lay out the type. If the C++ class has virtual primitives
2366 then the record must be declared as a tagged record type.
2367
2368 Types for which @code{CPP_Class} is specified do not have assignment or
2369 equality operators defined (such operations can be imported or declared
2370 as subprograms as required). Initialization is allowed only by constructor
2371 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2372 limited if not explicitly declared as limited or derived from a limited
2373 type, and an error is issued in that case.
2374
2375 See @ref{Interfacing to C++} for related information.
2376
2377 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2378 for backward compatibility but its functionality is available
2379 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2380
2381 @node Pragma CPP_Constructor
2382 @unnumberedsec Pragma CPP_Constructor
2383 @cindex Interfacing with C++
2384 @findex CPP_Constructor
2385 @noindent
2386 Syntax:
2387
2388 @smallexample @c ada
2389 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2390 [, [External_Name =>] static_string_EXPRESSION ]
2391 [, [Link_Name =>] static_string_EXPRESSION ]);
2392 @end smallexample
2393
2394 @noindent
2395 This pragma identifies an imported function (imported in the usual way
2396 with pragma @code{Import}) as corresponding to a C++ constructor. If
2397 @code{External_Name} and @code{Link_Name} are not specified then the
2398 @code{Entity} argument is a name that must have been previously mentioned
2399 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2400 must be of one of the following forms:
2401
2402 @itemize @bullet
2403 @item
2404 @code{function @var{Fname} return @var{T}}
2405
2406 @itemize @bullet
2407 @item
2408 @code{function @var{Fname} return @var{T}'Class}
2409
2410 @item
2411 @code{function @var{Fname} (@dots{}) return @var{T}}
2412 @end itemize
2413
2414 @item
2415 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2416 @end itemize
2417
2418 @noindent
2419 where @var{T} is a limited record type imported from C++ with pragma
2420 @code{Import} and @code{Convention} = @code{CPP}.
2421
2422 The first two forms import the default constructor, used when an object
2423 of type @var{T} is created on the Ada side with no explicit constructor.
2424 The latter two forms cover all the non-default constructors of the type.
2425 See the @value{EDITION} User's Guide for details.
2426
2427 If no constructors are imported, it is impossible to create any objects
2428 on the Ada side and the type is implicitly declared abstract.
2429
2430 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2431 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2432 GCC switch).
2433 See @ref{Interfacing to C++} for more related information.
2434
2435 Note: The use of functions returning class-wide types for constructors is
2436 currently obsolete. They are supported for backward compatibility. The
2437 use of functions returning the type T leave the Ada sources more clear
2438 because the imported C++ constructors always return an object of type T;
2439 that is, they never return an object whose type is a descendant of type T.
2440
2441 @node Pragma CPP_Virtual
2442 @unnumberedsec Pragma CPP_Virtual
2443 @cindex Interfacing to C++
2444 @findex CPP_Virtual
2445 @noindent
2446 This pragma is now obsolete and, other than generating a warning if warnings
2447 on obsolescent features are enabled, is completely ignored.
2448 It is retained for compatibility
2449 purposes. It used to be required to ensure compoatibility with C++, but
2450 is no longer required for that purpose because GNAT generates
2451 the same object layout as the G++ compiler by default.
2452
2453 See @ref{Interfacing to C++} for related information.
2454
2455 @node Pragma CPP_Vtable
2456 @unnumberedsec Pragma CPP_Vtable
2457 @cindex Interfacing with C++
2458 @findex CPP_Vtable
2459 @noindent
2460 This pragma is now obsolete and, other than generating a warning if warnings
2461 on obsolescent features are enabled, is completely ignored.
2462 It used to be required to ensure compatibility with C++, but
2463 is no longer required for that purpose because GNAT generates
2464 the same object layout as the G++ compiler by default.
2465
2466 See @ref{Interfacing to C++} for related information.
2467
2468 @node Pragma CPU
2469 @unnumberedsec Pragma CPU
2470 @findex CPU
2471 @noindent
2472 Syntax:
2473
2474 @smallexample @c ada
2475 pragma CPU (EXPRESSION);
2476 @end smallexample
2477
2478 @noindent
2479 This pragma is standard in Ada 2012, but is available in all earlier
2480 versions of Ada as an implementation-defined pragma.
2481 See Ada 2012 Reference Manual for details.
2482
2483 @node Pragma Debug
2484 @unnumberedsec Pragma Debug
2485 @findex Debug
2486 @noindent
2487 Syntax:
2488
2489 @smallexample @c ada
2490 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2491
2492 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2493 PROCEDURE_NAME
2494 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2495 @end smallexample
2496
2497 @noindent
2498 The procedure call argument has the syntactic form of an expression, meeting
2499 the syntactic requirements for pragmas.
2500
2501 If debug pragmas are not enabled or if the condition is present and evaluates
2502 to False, this pragma has no effect. If debug pragmas are enabled, the
2503 semantics of the pragma is exactly equivalent to the procedure call statement
2504 corresponding to the argument with a terminating semicolon. Pragmas are
2505 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2506 intersperse calls to debug procedures in the middle of declarations. Debug
2507 pragmas can be enabled either by use of the command line switch @option{-gnata}
2508 or by use of the pragma @code{Check_Policy} with a first argument of
2509 @code{Debug}.
2510
2511 @node Pragma Debug_Policy
2512 @unnumberedsec Pragma Debug_Policy
2513 @findex Debug_Policy
2514 @noindent
2515 Syntax:
2516
2517 @smallexample @c ada
2518 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2519 @end smallexample
2520
2521 @noindent
2522 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2523 with a first argument of @code{Debug}. It is retained for historical
2524 compatibility reasons.
2525
2526 @node Pragma Default_Scalar_Storage_Order
2527 @unnumberedsec Pragma Default_Scalar_Storage_Order
2528 @cindex Default_Scalar_Storage_Order
2529 @cindex Scalar_Storage_Order
2530 @findex Default_Scalar_Storage_Order
2531 @noindent
2532 Syntax:
2533
2534 @smallexample @c ada
2535 pragma Default_Scalar_Storage_Order (High_Order_First | Low_Order_First);
2536 @end smallexample
2537
2538 @noindent
2539 Normally if no explicit @code{Scalar_Storage_Order} is given for a record
2540 type or array type, then the scalar storage order defaults to the ordinary
2541 default for the target. But this default may be overridden using this pragma.
2542 The pragma may appear as a configuration pragma, or locally within a package
2543 spec or declarative part. In the latter case, it applies to all subsequent
2544 types declared within that package spec or declarative part.
2545
2546 If this pragma is used as a configuration pragma which appears within a
2547 configuration pragma file (as opposed to appearing explicitly at the start
2548 of a single unit), then the binder will require that all units in a partition
2549 be compiled in a similar manner, including all units in the run-time that
2550 are included in the partition.
2551
2552 The following example shows the use of this pragma:
2553
2554 @smallexample @c ada
2555 pragma Default_Scalar_Storage_Order (High_Order_First);
2556 with System; use System;
2557 package DSSO1 is
2558 type H1 is record
2559 a : Integer;
2560 end record;
2561
2562 type L2 is record
2563 a : Integer;
2564 end record;
2565 for L2'Scalar_Storage_Order use Low_Order_First;
2566
2567 type L2a is new L2;
2568
2569 package Inner is
2570 type H3 is record
2571 a : Integer;
2572 end record;
2573
2574 pragma Default_Scalar_Storage_Order (Low_Order_First);
2575
2576 type L4 is record
2577 a : Integer;
2578 end record;
2579 end Inner;
2580
2581 type H4a is new Inner.L4;
2582
2583 type H5 is record
2584 a : Integer;
2585 end record;
2586 end DSSO1;
2587 @end smallexample
2588
2589 @noindent
2590 In this example record types L.. have @code{Low_Order_First} scalar
2591 storage order, and record types H.. have @code{High_Order_First}.
2592 Note that in the case of @code{H4a}, the order is not inherited
2593 from the parent type. Only an explicitly set @code{Scalar_Storage_Order}
2594 gets inherited on type derivation.
2595
2596 @node Pragma Default_Storage_Pool
2597 @unnumberedsec Pragma Default_Storage_Pool
2598 @cindex Default_Storage_Pool
2599 @findex Default_Storage_Pool
2600 @noindent
2601 Syntax:
2602
2603 @smallexample @c ada
2604 pragma Default_Storage_Pool (storage_pool_NAME | null);
2605 @end smallexample
2606
2607 @noindent
2608 This pragma is standard in Ada 2012, but is available in all earlier
2609 versions of Ada as an implementation-defined pragma.
2610 See Ada 2012 Reference Manual for details.
2611
2612 @node Pragma Depends
2613 @unnumberedsec Pragma Depends
2614 @findex Depends
2615 @noindent
2616 For the description of this pragma, see SPARK 2014 Reference Manual,
2617 section 6.1.5.
2618
2619 @node Pragma Detect_Blocking
2620 @unnumberedsec Pragma Detect_Blocking
2621 @findex Detect_Blocking
2622 @noindent
2623 Syntax:
2624
2625 @smallexample @c ada
2626 pragma Detect_Blocking;
2627 @end smallexample
2628
2629 @noindent
2630 This is a standard pragma in Ada 2005, that is available in all earlier
2631 versions of Ada as an implementation-defined pragma.
2632
2633 This is a configuration pragma that forces the detection of potentially
2634 blocking operations within a protected operation, and to raise Program_Error
2635 if that happens.
2636
2637 @node Pragma Disable_Atomic_Synchronization
2638 @unnumberedsec Pragma Disable_Atomic_Synchronization
2639 @cindex Atomic Synchronization
2640 @findex Disable_Atomic_Synchronization
2641 @noindent
2642 Syntax:
2643
2644 @smallexample @c ada
2645 pragma Disable_Atomic_Synchronization [(Entity)];
2646 @end smallexample
2647
2648 @noindent
2649 Ada requires that accesses (reads or writes) of an atomic variable be
2650 regarded as synchronization points in the case of multiple tasks.
2651 Particularly in the case of multi-processors this may require special
2652 handling, e.g. the generation of memory barriers. This capability may
2653 be turned off using this pragma in cases where it is known not to be
2654 required.
2655
2656 The placement and scope rules for this pragma are the same as those
2657 for @code{pragma Suppress}. In particular it can be used as a
2658 configuration pragma, or in a declaration sequence where it applies
2659 till the end of the scope. If an @code{Entity} argument is present,
2660 the action applies only to that entity.
2661
2662 @node Pragma Dispatching_Domain
2663 @unnumberedsec Pragma Dispatching_Domain
2664 @findex Dispatching_Domain
2665 @noindent
2666 Syntax:
2667
2668 @smallexample @c ada
2669 pragma Dispatching_Domain (EXPRESSION);
2670 @end smallexample
2671
2672 @noindent
2673 This pragma is standard in Ada 2012, but is available in all earlier
2674 versions of Ada as an implementation-defined pragma.
2675 See Ada 2012 Reference Manual for details.
2676
2677 @node Pragma Effective_Reads
2678 @unnumberedsec Pragma Effective_Reads
2679 @findex Effective_Reads
2680 @noindent
2681 For the description of this pragma, see SPARK 2014 Reference Manual,
2682 section 7.1.2.
2683
2684 @node Pragma Effective_Writes
2685 @unnumberedsec Pragma Effective_Writes
2686 @findex Effective_Writes
2687 @noindent
2688 For the description of this pragma, see SPARK 2014 Reference Manual,
2689 section 7.1.2.
2690
2691 @node Pragma Elaboration_Checks
2692 @unnumberedsec Pragma Elaboration_Checks
2693 @cindex Elaboration control
2694 @findex Elaboration_Checks
2695 @noindent
2696 Syntax:
2697
2698 @smallexample @c ada
2699 pragma Elaboration_Checks (Dynamic | Static);
2700 @end smallexample
2701
2702 @noindent
2703 This is a configuration pragma that provides control over the
2704 elaboration model used by the compilation affected by the
2705 pragma. If the parameter is @code{Dynamic},
2706 then the dynamic elaboration
2707 model described in the Ada Reference Manual is used, as though
2708 the @option{-gnatE} switch had been specified on the command
2709 line. If the parameter is @code{Static}, then the default GNAT static
2710 model is used. This configuration pragma overrides the setting
2711 of the command line. For full details on the elaboration models
2712 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2713 gnat_ugn, @value{EDITION} User's Guide}.
2714
2715 @node Pragma Eliminate
2716 @unnumberedsec Pragma Eliminate
2717 @cindex Elimination of unused subprograms
2718 @findex Eliminate
2719 @noindent
2720 Syntax:
2721
2722 @smallexample @c ada
2723 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2724 [Source_Location =>] STRING_LITERAL);
2725 @end smallexample
2726
2727 @noindent
2728 The string literal given for the source location is a string which
2729 specifies the line number of the occurrence of the entity, using
2730 the syntax for SOURCE_TRACE given below:
2731
2732 @smallexample @c ada
2733 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2734
2735 LBRACKET ::= [
2736 RBRACKET ::= ]
2737
2738 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2739
2740 LINE_NUMBER ::= DIGIT @{DIGIT@}
2741 @end smallexample
2742
2743 @noindent
2744 Spaces around the colon in a @code{Source_Reference} are optional.
2745
2746 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2747 explicit subprogram declaration, where the @code{entity} name in this
2748 designator appears on the source line specified by the source location.
2749
2750 The source trace that is given as the @code{Source_Location} shall obey the
2751 following rules. The @code{FILE_NAME} is the short name (with no directory
2752 information) of an Ada source file, given using exactly the required syntax
2753 for the underlying file system (e.g. case is important if the underlying
2754 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2755 number of the occurrence of the @code{entity}
2756 as a decimal literal without an exponent or point. If an @code{entity} is not
2757 declared in a generic instantiation (this includes generic subprogram
2758 instances), the source trace includes only one source reference. If an entity
2759 is declared inside a generic instantiation, its source trace (when parsing
2760 from left to right) starts with the source location of the declaration of the
2761 entity in the generic unit and ends with the source location of the
2762 instantiation (it is given in square brackets). This approach is recursively
2763 used in case of nested instantiations: the rightmost (nested most deeply in
2764 square brackets) element of the source trace is the location of the outermost
2765 instantiation, the next to left element is the location of the next (first
2766 nested) instantiation in the code of the corresponding generic unit, and so
2767 on, and the leftmost element (that is out of any square brackets) is the
2768 location of the declaration of the entity to eliminate in a generic unit.
2769
2770 Note that the @code{Source_Location} argument specifies which of a set of
2771 similarly named entities is being eliminated, dealing both with overloading,
2772 and also appearance of the same entity name in different scopes.
2773
2774 This pragma indicates that the given entity is not used in the program to be
2775 compiled and built. The effect of the pragma is to allow the compiler to
2776 eliminate the code or data associated with the named entity. Any reference to
2777 an eliminated entity causes a compile-time or link-time error.
2778
2779 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2780 in a system-independent manner, with unused entities eliminated, without
2781 needing to modify the source text. Normally the required set of
2782 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2783
2784 Any source file change that removes, splits, or
2785 adds lines may make the set of Eliminate pragmas invalid because their
2786 @code{Source_Location} argument values may get out of date.
2787
2788 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2789 operation. In this case all the subprograms to which the given operation can
2790 dispatch are considered to be unused (are never called as a result of a direct
2791 or a dispatching call).
2792
2793 @node Pragma Enable_Atomic_Synchronization
2794 @unnumberedsec Pragma Enable_Atomic_Synchronization
2795 @cindex Atomic Synchronization
2796 @findex Enable_Atomic_Synchronization
2797 @noindent
2798 Syntax:
2799
2800 @smallexample @c ada
2801 pragma Enable_Atomic_Synchronization [(Entity)];
2802 @end smallexample
2803
2804 @noindent
2805 Ada requires that accesses (reads or writes) of an atomic variable be
2806 regarded as synchronization points in the case of multiple tasks.
2807 Particularly in the case of multi-processors this may require special
2808 handling, e.g. the generation of memory barriers. This synchronization
2809 is performed by default, but can be turned off using
2810 @code{pragma Disable_Atomic_Synchronization}. The
2811 @code{Enable_Atomic_Synchronization} pragma can be used to turn
2812 it back on.
2813
2814 The placement and scope rules for this pragma are the same as those
2815 for @code{pragma Unsuppress}. In particular it can be used as a
2816 configuration pragma, or in a declaration sequence where it applies
2817 till the end of the scope. If an @code{Entity} argument is present,
2818 the action applies only to that entity.
2819
2820 @node Pragma Export_Exception
2821 @unnumberedsec Pragma Export_Exception
2822 @cindex OpenVMS
2823 @findex Export_Exception
2824 @noindent
2825 Syntax:
2826
2827 @smallexample @c ada
2828 pragma Export_Exception (
2829 [Internal =>] LOCAL_NAME
2830 [, [External =>] EXTERNAL_SYMBOL]
2831 [, [Form =>] Ada | VMS]
2832 [, [Code =>] static_integer_EXPRESSION]);
2833
2834 EXTERNAL_SYMBOL ::=
2835 IDENTIFIER
2836 | static_string_EXPRESSION
2837 @end smallexample
2838
2839 @noindent
2840 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2841 causes the specified exception to be propagated outside of the Ada program,
2842 so that it can be handled by programs written in other OpenVMS languages.
2843 This pragma establishes an external name for an Ada exception and makes the
2844 name available to the OpenVMS Linker as a global symbol. For further details
2845 on this pragma, see the
2846 DEC Ada Language Reference Manual, section 13.9a3.2.
2847
2848 @node Pragma Export_Function
2849 @unnumberedsec Pragma Export_Function
2850 @cindex Argument passing mechanisms
2851 @findex Export_Function
2852
2853 @noindent
2854 Syntax:
2855
2856 @smallexample @c ada
2857 pragma Export_Function (
2858 [Internal =>] LOCAL_NAME
2859 [, [External =>] EXTERNAL_SYMBOL]
2860 [, [Parameter_Types =>] PARAMETER_TYPES]
2861 [, [Result_Type =>] result_SUBTYPE_MARK]
2862 [, [Mechanism =>] MECHANISM]
2863 [, [Result_Mechanism =>] MECHANISM_NAME]);
2864
2865 EXTERNAL_SYMBOL ::=
2866 IDENTIFIER
2867 | static_string_EXPRESSION
2868 | ""
2869
2870 PARAMETER_TYPES ::=
2871 null
2872 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2873
2874 TYPE_DESIGNATOR ::=
2875 subtype_NAME
2876 | subtype_Name ' Access
2877
2878 MECHANISM ::=
2879 MECHANISM_NAME
2880 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2881
2882 MECHANISM_ASSOCIATION ::=
2883 [formal_parameter_NAME =>] MECHANISM_NAME
2884
2885 MECHANISM_NAME ::=
2886 Value
2887 | Reference
2888 | Descriptor [([Class =>] CLASS_NAME)]
2889 | Short_Descriptor [([Class =>] CLASS_NAME)]
2890
2891 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2892 @end smallexample
2893
2894 @noindent
2895 Use this pragma to make a function externally callable and optionally
2896 provide information on mechanisms to be used for passing parameter and
2897 result values. We recommend, for the purposes of improving portability,
2898 this pragma always be used in conjunction with a separate pragma
2899 @code{Export}, which must precede the pragma @code{Export_Function}.
2900 GNAT does not require a separate pragma @code{Export}, but if none is
2901 present, @code{Convention Ada} is assumed, which is usually
2902 not what is wanted, so it is usually appropriate to use this
2903 pragma in conjunction with a @code{Export} or @code{Convention}
2904 pragma that specifies the desired foreign convention.
2905 Pragma @code{Export_Function}
2906 (and @code{Export}, if present) must appear in the same declarative
2907 region as the function to which they apply.
2908
2909 @var{internal_name} must uniquely designate the function to which the
2910 pragma applies. If more than one function name exists of this name in
2911 the declarative part you must use the @code{Parameter_Types} and
2912 @code{Result_Type} parameters is mandatory to achieve the required
2913 unique designation. @var{subtype_mark}s in these parameters must
2914 exactly match the subtypes in the corresponding function specification,
2915 using positional notation to match parameters with subtype marks.
2916 The form with an @code{'Access} attribute can be used to match an
2917 anonymous access parameter.
2918
2919 @cindex OpenVMS
2920 @cindex Passing by descriptor
2921 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2922 The default behavior for Export_Function is to accept either 64bit or
2923 32bit descriptors unless short_descriptor is specified, then only 32bit
2924 descriptors are accepted.
2925
2926 @cindex Suppressing external name
2927 Special treatment is given if the EXTERNAL is an explicit null
2928 string or a static string expressions that evaluates to the null
2929 string. In this case, no external name is generated. This form
2930 still allows the specification of parameter mechanisms.
2931
2932 @node Pragma Export_Object
2933 @unnumberedsec Pragma Export_Object
2934 @findex Export_Object
2935 @noindent
2936 Syntax:
2937
2938 @smallexample @c ada
2939 pragma Export_Object
2940 [Internal =>] LOCAL_NAME
2941 [, [External =>] EXTERNAL_SYMBOL]
2942 [, [Size =>] EXTERNAL_SYMBOL]
2943
2944 EXTERNAL_SYMBOL ::=
2945 IDENTIFIER
2946 | static_string_EXPRESSION
2947 @end smallexample
2948
2949 @noindent
2950 This pragma designates an object as exported, and apart from the
2951 extended rules for external symbols, is identical in effect to the use of
2952 the normal @code{Export} pragma applied to an object. You may use a
2953 separate Export pragma (and you probably should from the point of view
2954 of portability), but it is not required. @var{Size} is syntax checked,
2955 but otherwise ignored by GNAT@.
2956
2957 @node Pragma Export_Procedure
2958 @unnumberedsec Pragma Export_Procedure
2959 @findex Export_Procedure
2960 @noindent
2961 Syntax:
2962
2963 @smallexample @c ada
2964 pragma Export_Procedure (
2965 [Internal =>] LOCAL_NAME
2966 [, [External =>] EXTERNAL_SYMBOL]
2967 [, [Parameter_Types =>] PARAMETER_TYPES]
2968 [, [Mechanism =>] MECHANISM]);
2969
2970 EXTERNAL_SYMBOL ::=
2971 IDENTIFIER
2972 | static_string_EXPRESSION
2973 | ""
2974
2975 PARAMETER_TYPES ::=
2976 null
2977 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2978
2979 TYPE_DESIGNATOR ::=
2980 subtype_NAME
2981 | subtype_Name ' Access
2982
2983 MECHANISM ::=
2984 MECHANISM_NAME
2985 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2986
2987 MECHANISM_ASSOCIATION ::=
2988 [formal_parameter_NAME =>] MECHANISM_NAME
2989
2990 MECHANISM_NAME ::=
2991 Value
2992 | Reference
2993 | Descriptor [([Class =>] CLASS_NAME)]
2994 | Short_Descriptor [([Class =>] CLASS_NAME)]
2995
2996 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2997 @end smallexample
2998
2999 @noindent
3000 This pragma is identical to @code{Export_Function} except that it
3001 applies to a procedure rather than a function and the parameters
3002 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3003 GNAT does not require a separate pragma @code{Export}, but if none is
3004 present, @code{Convention Ada} is assumed, which is usually
3005 not what is wanted, so it is usually appropriate to use this
3006 pragma in conjunction with a @code{Export} or @code{Convention}
3007 pragma that specifies the desired foreign convention.
3008
3009 @cindex OpenVMS
3010 @cindex Passing by descriptor
3011 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3012 The default behavior for Export_Procedure is to accept either 64bit or
3013 32bit descriptors unless short_descriptor is specified, then only 32bit
3014 descriptors are accepted.
3015
3016 @cindex Suppressing external name
3017 Special treatment is given if the EXTERNAL is an explicit null
3018 string or a static string expressions that evaluates to the null
3019 string. In this case, no external name is generated. This form
3020 still allows the specification of parameter mechanisms.
3021
3022 @node Pragma Export_Value
3023 @unnumberedsec Pragma Export_Value
3024 @findex Export_Value
3025 @noindent
3026 Syntax:
3027
3028 @smallexample @c ada
3029 pragma Export_Value (
3030 [Value =>] static_integer_EXPRESSION,
3031 [Link_Name =>] static_string_EXPRESSION);
3032 @end smallexample
3033
3034 @noindent
3035 This pragma serves to export a static integer value for external use.
3036 The first argument specifies the value to be exported. The Link_Name
3037 argument specifies the symbolic name to be associated with the integer
3038 value. This pragma is useful for defining a named static value in Ada
3039 that can be referenced in assembly language units to be linked with
3040 the application. This pragma is currently supported only for the
3041 AAMP target and is ignored for other targets.
3042
3043 @node Pragma Export_Valued_Procedure
3044 @unnumberedsec Pragma Export_Valued_Procedure
3045 @findex Export_Valued_Procedure
3046 @noindent
3047 Syntax:
3048
3049 @smallexample @c ada
3050 pragma Export_Valued_Procedure (
3051 [Internal =>] LOCAL_NAME
3052 [, [External =>] EXTERNAL_SYMBOL]
3053 [, [Parameter_Types =>] PARAMETER_TYPES]
3054 [, [Mechanism =>] MECHANISM]);
3055
3056 EXTERNAL_SYMBOL ::=
3057 IDENTIFIER
3058 | static_string_EXPRESSION
3059 | ""
3060
3061 PARAMETER_TYPES ::=
3062 null
3063 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3064
3065 TYPE_DESIGNATOR ::=
3066 subtype_NAME
3067 | subtype_Name ' Access
3068
3069 MECHANISM ::=
3070 MECHANISM_NAME
3071 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3072
3073 MECHANISM_ASSOCIATION ::=
3074 [formal_parameter_NAME =>] MECHANISM_NAME
3075
3076 MECHANISM_NAME ::=
3077 Value
3078 | Reference
3079 | Descriptor [([Class =>] CLASS_NAME)]
3080 | Short_Descriptor [([Class =>] CLASS_NAME)]
3081
3082 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
3083 @end smallexample
3084
3085 @noindent
3086 This pragma is identical to @code{Export_Procedure} except that the
3087 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3088 mode @code{OUT}, and externally the subprogram is treated as a function
3089 with this parameter as the result of the function. GNAT provides for
3090 this capability to allow the use of @code{OUT} and @code{IN OUT}
3091 parameters in interfacing to external functions (which are not permitted
3092 in Ada functions).
3093 GNAT does not require a separate pragma @code{Export}, but if none is
3094 present, @code{Convention Ada} is assumed, which is almost certainly
3095 not what is wanted since the whole point of this pragma is to interface
3096 with foreign language functions, so it is usually appropriate to use this
3097 pragma in conjunction with a @code{Export} or @code{Convention}
3098 pragma that specifies the desired foreign convention.
3099
3100 @cindex OpenVMS
3101 @cindex Passing by descriptor
3102 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3103 The default behavior for Export_Valued_Procedure is to accept either 64bit or
3104 32bit descriptors unless short_descriptor is specified, then only 32bit
3105 descriptors are accepted.
3106
3107 @cindex Suppressing external name
3108 Special treatment is given if the EXTERNAL is an explicit null
3109 string or a static string expressions that evaluates to the null
3110 string. In this case, no external name is generated. This form
3111 still allows the specification of parameter mechanisms.
3112
3113 @node Pragma Extend_System
3114 @unnumberedsec Pragma Extend_System
3115 @cindex @code{system}, extending
3116 @cindex Dec Ada 83
3117 @findex Extend_System
3118 @noindent
3119 Syntax:
3120
3121 @smallexample @c ada
3122 pragma Extend_System ([Name =>] IDENTIFIER);
3123 @end smallexample
3124
3125 @noindent
3126 This pragma is used to provide backwards compatibility with other
3127 implementations that extend the facilities of package @code{System}. In
3128 GNAT, @code{System} contains only the definitions that are present in
3129 the Ada RM@. However, other implementations, notably the DEC Ada 83
3130 implementation, provide many extensions to package @code{System}.
3131
3132 For each such implementation accommodated by this pragma, GNAT provides a
3133 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
3134 implementation, which provides the required additional definitions. You
3135 can use this package in two ways. You can @code{with} it in the normal
3136 way and access entities either by selection or using a @code{use}
3137 clause. In this case no special processing is required.
3138
3139 However, if existing code contains references such as
3140 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
3141 definitions provided in package @code{System}, you may use this pragma
3142 to extend visibility in @code{System} in a non-standard way that
3143 provides greater compatibility with the existing code. Pragma
3144 @code{Extend_System} is a configuration pragma whose single argument is
3145 the name of the package containing the extended definition
3146 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
3147 control of this pragma will be processed using special visibility
3148 processing that looks in package @code{System.Aux_@var{xxx}} where
3149 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
3150 package @code{System}, but not found in package @code{System}.
3151
3152 You can use this pragma either to access a predefined @code{System}
3153 extension supplied with the compiler, for example @code{Aux_DEC} or
3154 you can construct your own extension unit following the above
3155 definition. Note that such a package is a child of @code{System}
3156 and thus is considered part of the implementation.
3157 To compile it you will have to use the @option{-gnatg} switch,
3158 or the @option{/GNAT_INTERNAL} qualifier on OpenVMS,
3159 for compiling System units, as explained in the
3160 @value{EDITION} User's Guide.
3161
3162 @node Pragma Extensions_Allowed
3163 @unnumberedsec Pragma Extensions_Allowed
3164 @cindex Ada Extensions
3165 @cindex GNAT Extensions
3166 @findex Extensions_Allowed
3167 @noindent
3168 Syntax:
3169
3170 @smallexample @c ada
3171 pragma Extensions_Allowed (On | Off);
3172 @end smallexample
3173
3174 @noindent
3175 This configuration pragma enables or disables the implementation
3176 extension mode (the use of Off as a parameter cancels the effect
3177 of the @option{-gnatX} command switch).
3178
3179 In extension mode, the latest version of the Ada language is
3180 implemented (currently Ada 2012), and in addition a small number
3181 of GNAT specific extensions are recognized as follows:
3182
3183 @table @asis
3184 @item Constrained attribute for generic objects
3185 The @code{Constrained} attribute is permitted for objects of
3186 generic types. The result indicates if the corresponding actual
3187 is constrained.
3188
3189 @end table
3190
3191 @node Pragma External
3192 @unnumberedsec Pragma External
3193 @findex External
3194 @noindent
3195 Syntax:
3196
3197 @smallexample @c ada
3198 pragma External (
3199 [ Convention =>] convention_IDENTIFIER,
3200 [ Entity =>] LOCAL_NAME
3201 [, [External_Name =>] static_string_EXPRESSION ]
3202 [, [Link_Name =>] static_string_EXPRESSION ]);
3203 @end smallexample
3204
3205 @noindent
3206 This pragma is identical in syntax and semantics to pragma
3207 @code{Export} as defined in the Ada Reference Manual. It is
3208 provided for compatibility with some Ada 83 compilers that
3209 used this pragma for exactly the same purposes as pragma
3210 @code{Export} before the latter was standardized.
3211
3212 @node Pragma External_Name_Casing
3213 @unnumberedsec Pragma External_Name_Casing
3214 @cindex Dec Ada 83 casing compatibility
3215 @cindex External Names, casing
3216 @cindex Casing of External names
3217 @findex External_Name_Casing
3218 @noindent
3219 Syntax:
3220
3221 @smallexample @c ada
3222 pragma External_Name_Casing (
3223 Uppercase | Lowercase
3224 [, Uppercase | Lowercase | As_Is]);
3225 @end smallexample
3226
3227 @noindent
3228 This pragma provides control over the casing of external names associated
3229 with Import and Export pragmas. There are two cases to consider:
3230
3231 @table @asis
3232 @item Implicit external names
3233 Implicit external names are derived from identifiers. The most common case
3234 arises when a standard Ada Import or Export pragma is used with only two
3235 arguments, as in:
3236
3237 @smallexample @c ada
3238 pragma Import (C, C_Routine);
3239 @end smallexample
3240
3241 @noindent
3242 Since Ada is a case-insensitive language, the spelling of the identifier in
3243 the Ada source program does not provide any information on the desired
3244 casing of the external name, and so a convention is needed. In GNAT the
3245 default treatment is that such names are converted to all lower case
3246 letters. This corresponds to the normal C style in many environments.
3247 The first argument of pragma @code{External_Name_Casing} can be used to
3248 control this treatment. If @code{Uppercase} is specified, then the name
3249 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3250 then the normal default of all lower case letters will be used.
3251
3252 This same implicit treatment is also used in the case of extended DEC Ada 83
3253 compatible Import and Export pragmas where an external name is explicitly
3254 specified using an identifier rather than a string.
3255
3256 @item Explicit external names
3257 Explicit external names are given as string literals. The most common case
3258 arises when a standard Ada Import or Export pragma is used with three
3259 arguments, as in:
3260
3261 @smallexample @c ada
3262 pragma Import (C, C_Routine, "C_routine");
3263 @end smallexample
3264
3265 @noindent
3266 In this case, the string literal normally provides the exact casing required
3267 for the external name. The second argument of pragma
3268 @code{External_Name_Casing} may be used to modify this behavior.
3269 If @code{Uppercase} is specified, then the name
3270 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3271 then the name will be forced to all lowercase letters. A specification of
3272 @code{As_Is} provides the normal default behavior in which the casing is
3273 taken from the string provided.
3274 @end table
3275
3276 @noindent
3277 This pragma may appear anywhere that a pragma is valid. In particular, it
3278 can be used as a configuration pragma in the @file{gnat.adc} file, in which
3279 case it applies to all subsequent compilations, or it can be used as a program
3280 unit pragma, in which case it only applies to the current unit, or it can
3281 be used more locally to control individual Import/Export pragmas.
3282
3283 It is primarily intended for use with OpenVMS systems, where many
3284 compilers convert all symbols to upper case by default. For interfacing to
3285 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
3286 the pragma:
3287
3288 @smallexample @c ada
3289 pragma External_Name_Casing (Uppercase, Uppercase);
3290 @end smallexample
3291
3292 @noindent
3293 to enforce the upper casing of all external symbols.
3294
3295 @node Pragma Fast_Math
3296 @unnumberedsec Pragma Fast_Math
3297 @findex Fast_Math
3298 @noindent
3299 Syntax:
3300
3301 @smallexample @c ada
3302 pragma Fast_Math;
3303 @end smallexample
3304
3305 @noindent
3306 This is a configuration pragma which activates a mode in which speed is
3307 considered more important for floating-point operations than absolutely
3308 accurate adherence to the requirements of the standard. Currently the
3309 following operations are affected:
3310
3311 @table @asis
3312 @item Complex Multiplication
3313 The normal simple formula for complex multiplication can result in intermediate
3314 overflows for numbers near the end of the range. The Ada standard requires that
3315 this situation be detected and corrected by scaling, but in Fast_Math mode such
3316 cases will simply result in overflow. Note that to take advantage of this you
3317 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3318 under control of the pragma, rather than use the preinstantiated versions.
3319 @end table
3320
3321 @node Pragma Favor_Top_Level
3322 @unnumberedsec Pragma Favor_Top_Level
3323 @findex Favor_Top_Level
3324 @noindent
3325 Syntax:
3326
3327 @smallexample @c ada
3328 pragma Favor_Top_Level (type_NAME);
3329 @end smallexample
3330
3331 @noindent
3332 The named type must be an access-to-subprogram type. This pragma is an
3333 efficiency hint to the compiler, regarding the use of 'Access or
3334 'Unrestricted_Access on nested (non-library-level) subprograms. The
3335 pragma means that nested subprograms are not used with this type, or
3336 are rare, so that the generated code should be efficient in the
3337 top-level case. When this pragma is used, dynamically generated
3338 trampolines may be used on some targets for nested subprograms.
3339 See also the No_Implicit_Dynamic_Code restriction.
3340
3341 @node Pragma Finalize_Storage_Only
3342 @unnumberedsec Pragma Finalize_Storage_Only
3343 @findex Finalize_Storage_Only
3344 @noindent
3345 Syntax:
3346
3347 @smallexample @c ada
3348 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3349 @end smallexample
3350
3351 @noindent
3352 This pragma allows the compiler not to emit a Finalize call for objects
3353 defined at the library level. This is mostly useful for types where
3354 finalization is only used to deal with storage reclamation since in most
3355 environments it is not necessary to reclaim memory just before terminating
3356 execution, hence the name.
3357
3358 @node Pragma Float_Representation
3359 @unnumberedsec Pragma Float_Representation
3360 @cindex OpenVMS
3361 @findex Float_Representation
3362 @noindent
3363 Syntax:
3364
3365 @smallexample @c ada
3366 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3367
3368 FLOAT_REP ::= VAX_Float | IEEE_Float
3369 @end smallexample
3370
3371 @noindent
3372 In the one argument form, this pragma is a configuration pragma which
3373 allows control over the internal representation chosen for the predefined
3374 floating point types declared in the packages @code{Standard} and
3375 @code{System}. On all systems other than OpenVMS, the argument must
3376 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
3377 argument may be @code{VAX_Float} to specify the use of the VAX float
3378 format for the floating-point types in Standard. This requires that
3379 the standard runtime libraries be recompiled.
3380
3381 The two argument form specifies the representation to be used for
3382 the specified floating-point type. On all systems other than OpenVMS,
3383 the argument must
3384 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3385
3386 @itemize @bullet
3387 @item
3388 For a digits value of 6, 32-bit IEEE short format will be used.
3389 @item
3390 For a digits value of 15, 64-bit IEEE long format will be used.
3391 @item
3392 No other value of digits is permitted.
3393 @end itemize
3394
3395 On OpenVMS, the
3396 argument may be @code{VAX_Float} to specify the use of the VAX float
3397 format, as follows:
3398
3399 @itemize @bullet
3400 @item
3401 For digits values up to 6, F float format will be used.
3402 @item
3403 For digits values from 7 to 9, D float format will be used.
3404 @item
3405 For digits values from 10 to 15, G float format will be used.
3406 @item
3407 Digits values above 15 are not allowed.
3408 @end itemize
3409
3410 @node Pragma Global
3411 @unnumberedsec Pragma Global
3412 @findex Global
3413 @noindent
3414 For the description of this pragma, see SPARK 2014 Reference Manual,
3415 section 6.1.4.
3416
3417 @node Pragma Ident
3418 @unnumberedsec Pragma Ident
3419 @findex Ident
3420 @noindent
3421 Syntax:
3422
3423 @smallexample @c ada
3424 pragma Ident (static_string_EXPRESSION);
3425 @end smallexample
3426
3427 @noindent
3428 This pragma provides a string identification in the generated object file,
3429 if the system supports the concept of this kind of identification string.
3430 This pragma is allowed only in the outermost declarative part or
3431 declarative items of a compilation unit. If more than one @code{Ident}
3432 pragma is given, only the last one processed is effective.
3433 @cindex OpenVMS
3434 On OpenVMS systems, the effect of the pragma is identical to the effect of
3435 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
3436 maximum allowed length is 31 characters, so if it is important to
3437 maintain compatibility with this compiler, you should obey this length
3438 limit.
3439
3440 @node Pragma Implementation_Defined
3441 @unnumberedsec Pragma Implementation_Defined
3442 @findex Implementation_Defined
3443 @noindent
3444 Syntax:
3445
3446 @smallexample @c ada
3447 pragma Implementation_Defined (local_NAME);
3448 @end smallexample
3449
3450 @noindent
3451 This pragma marks a previously declared entioty as implementation-defined.
3452 For an overloaded entity, applies to the most recent homonym.
3453
3454 @smallexample @c ada
3455 pragma Implementation_Defined;
3456 @end smallexample
3457
3458 @noindent
3459 The form with no arguments appears anywhere within a scope, most
3460 typically a package spec, and indicates that all entities that are
3461 defined within the package spec are Implementation_Defined.
3462
3463 This pragma is used within the GNAT runtime library to identify
3464 implementation-defined entities introduced in language-defined units,
3465 for the purpose of implementing the No_Implementation_Identifiers
3466 restriction.
3467
3468 @node Pragma Implemented
3469 @unnumberedsec Pragma Implemented
3470 @findex Implemented
3471 @noindent
3472 Syntax:
3473
3474 @smallexample @c ada
3475 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3476
3477 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3478 @end smallexample
3479
3480 @noindent
3481 This is an Ada 2012 representation pragma which applies to protected, task
3482 and synchronized interface primitives. The use of pragma Implemented provides
3483 a way to impose a static requirement on the overriding operation by adhering
3484 to one of the three implementation kinds: entry, protected procedure or any of
3485 the above. This pragma is available in all earlier versions of Ada as an
3486 implementation-defined pragma.
3487
3488 @smallexample @c ada
3489 type Synch_Iface is synchronized interface;
3490 procedure Prim_Op (Obj : in out Iface) is abstract;
3491 pragma Implemented (Prim_Op, By_Protected_Procedure);
3492
3493 protected type Prot_1 is new Synch_Iface with
3494 procedure Prim_Op; -- Legal
3495 end Prot_1;
3496
3497 protected type Prot_2 is new Synch_Iface with
3498 entry Prim_Op; -- Illegal
3499 end Prot_2;
3500
3501 task type Task_Typ is new Synch_Iface with
3502 entry Prim_Op; -- Illegal
3503 end Task_Typ;
3504 @end smallexample
3505
3506 @noindent
3507 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
3508 Implemented determines the runtime behavior of the requeue. Implementation kind
3509 By_Entry guarantees that the action of requeueing will proceed from an entry to
3510 another entry. Implementation kind By_Protected_Procedure transforms the
3511 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
3512 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
3513 the target's overriding subprogram kind.
3514
3515 @node Pragma Implicit_Packing
3516 @unnumberedsec Pragma Implicit_Packing
3517 @findex Implicit_Packing
3518 @cindex Rational Profile
3519 @noindent
3520 Syntax:
3521
3522 @smallexample @c ada
3523 pragma Implicit_Packing;
3524 @end smallexample
3525
3526 @noindent
3527 This is a configuration pragma that requests implicit packing for packed
3528 arrays for which a size clause is given but no explicit pragma Pack or
3529 specification of Component_Size is present. It also applies to records
3530 where no record representation clause is present. Consider this example:
3531
3532 @smallexample @c ada
3533 type R is array (0 .. 7) of Boolean;
3534 for R'Size use 8;
3535 @end smallexample
3536
3537 @noindent
3538 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3539 does not change the layout of a composite object. So the Size clause in the
3540 above example is normally rejected, since the default layout of the array uses
3541 8-bit components, and thus the array requires a minimum of 64 bits.
3542
3543 If this declaration is compiled in a region of code covered by an occurrence
3544 of the configuration pragma Implicit_Packing, then the Size clause in this
3545 and similar examples will cause implicit packing and thus be accepted. For
3546 this implicit packing to occur, the type in question must be an array of small
3547 components whose size is known at compile time, and the Size clause must
3548 specify the exact size that corresponds to the number of elements in the array
3549 multiplied by the size in bits of the component type (both single and
3550 multi-dimensioned arrays can be controlled with this pragma).
3551
3552 @cindex Array packing
3553
3554 Similarly, the following example shows the use in the record case
3555
3556 @smallexample @c ada
3557 type r is record
3558 a, b, c, d, e, f, g, h : boolean;
3559 chr : character;
3560 end record;
3561 for r'size use 16;
3562 @end smallexample
3563
3564 @noindent
3565 Without a pragma Pack, each Boolean field requires 8 bits, so the
3566 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3567 sufficient. The use of pragma Implicit_Packing allows this record
3568 declaration to compile without an explicit pragma Pack.
3569 @node Pragma Import_Exception
3570 @unnumberedsec Pragma Import_Exception
3571 @cindex OpenVMS
3572 @findex Import_Exception
3573 @noindent
3574 Syntax:
3575
3576 @smallexample @c ada
3577 pragma Import_Exception (
3578 [Internal =>] LOCAL_NAME
3579 [, [External =>] EXTERNAL_SYMBOL]
3580 [, [Form =>] Ada | VMS]
3581 [, [Code =>] static_integer_EXPRESSION]);
3582
3583 EXTERNAL_SYMBOL ::=
3584 IDENTIFIER
3585 | static_string_EXPRESSION
3586 @end smallexample
3587
3588 @noindent
3589 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3590 It allows OpenVMS conditions (for example, from OpenVMS system services or
3591 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3592 The pragma specifies that the exception associated with an exception
3593 declaration in an Ada program be defined externally (in non-Ada code).
3594 For further details on this pragma, see the
3595 DEC Ada Language Reference Manual, section 13.9a.3.1.
3596
3597 @node Pragma Import_Function
3598 @unnumberedsec Pragma Import_Function
3599 @findex Import_Function
3600 @noindent
3601 Syntax:
3602
3603 @smallexample @c ada
3604 pragma Import_Function (
3605 [Internal =>] LOCAL_NAME,
3606 [, [External =>] EXTERNAL_SYMBOL]
3607 [, [Parameter_Types =>] PARAMETER_TYPES]
3608 [, [Result_Type =>] SUBTYPE_MARK]
3609 [, [Mechanism =>] MECHANISM]
3610 [, [Result_Mechanism =>] MECHANISM_NAME]
3611 [, [First_Optional_Parameter =>] IDENTIFIER]);
3612
3613 EXTERNAL_SYMBOL ::=
3614 IDENTIFIER
3615 | static_string_EXPRESSION
3616
3617 PARAMETER_TYPES ::=
3618 null
3619 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3620
3621 TYPE_DESIGNATOR ::=
3622 subtype_NAME
3623 | subtype_Name ' Access
3624
3625 MECHANISM ::=
3626 MECHANISM_NAME
3627 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3628
3629 MECHANISM_ASSOCIATION ::=
3630 [formal_parameter_NAME =>] MECHANISM_NAME
3631
3632 MECHANISM_NAME ::=
3633 Value
3634 | Reference
3635 | Descriptor [([Class =>] CLASS_NAME)]
3636 | Short_Descriptor [([Class =>] CLASS_NAME)]
3637
3638 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3639 @end smallexample
3640
3641 @noindent
3642 This pragma is used in conjunction with a pragma @code{Import} to
3643 specify additional information for an imported function. The pragma
3644 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3645 @code{Import_Function} pragma and both must appear in the same
3646 declarative part as the function specification.
3647
3648 The @var{Internal} argument must uniquely designate
3649 the function to which the
3650 pragma applies. If more than one function name exists of this name in
3651 the declarative part you must use the @code{Parameter_Types} and
3652 @var{Result_Type} parameters to achieve the required unique
3653 designation. Subtype marks in these parameters must exactly match the
3654 subtypes in the corresponding function specification, using positional
3655 notation to match parameters with subtype marks.
3656 The form with an @code{'Access} attribute can be used to match an
3657 anonymous access parameter.
3658
3659 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3660 parameters to specify passing mechanisms for the
3661 parameters and result. If you specify a single mechanism name, it
3662 applies to all parameters. Otherwise you may specify a mechanism on a
3663 parameter by parameter basis using either positional or named
3664 notation. If the mechanism is not specified, the default mechanism
3665 is used.
3666
3667 @cindex OpenVMS
3668 @cindex Passing by descriptor
3669 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3670 The default behavior for Import_Function is to pass a 64bit descriptor
3671 unless short_descriptor is specified, then a 32bit descriptor is passed.
3672
3673 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3674 It specifies that the designated parameter and all following parameters
3675 are optional, meaning that they are not passed at the generated code
3676 level (this is distinct from the notion of optional parameters in Ada
3677 where the parameters are passed anyway with the designated optional
3678 parameters). All optional parameters must be of mode @code{IN} and have
3679 default parameter values that are either known at compile time
3680 expressions, or uses of the @code{'Null_Parameter} attribute.
3681
3682 @node Pragma Import_Object
3683 @unnumberedsec Pragma Import_Object
3684 @findex Import_Object
3685 @noindent
3686 Syntax:
3687
3688 @smallexample @c ada
3689 pragma Import_Object
3690 [Internal =>] LOCAL_NAME
3691 [, [External =>] EXTERNAL_SYMBOL]
3692 [, [Size =>] EXTERNAL_SYMBOL]);
3693
3694 EXTERNAL_SYMBOL ::=
3695 IDENTIFIER
3696 | static_string_EXPRESSION
3697 @end smallexample
3698
3699 @noindent
3700 This pragma designates an object as imported, and apart from the
3701 extended rules for external symbols, is identical in effect to the use of
3702 the normal @code{Import} pragma applied to an object. Unlike the
3703 subprogram case, you need not use a separate @code{Import} pragma,
3704 although you may do so (and probably should do so from a portability
3705 point of view). @var{size} is syntax checked, but otherwise ignored by
3706 GNAT@.
3707
3708 @node Pragma Import_Procedure
3709 @unnumberedsec Pragma Import_Procedure
3710 @findex Import_Procedure
3711 @noindent
3712 Syntax:
3713
3714 @smallexample @c ada
3715 pragma Import_Procedure (
3716 [Internal =>] LOCAL_NAME
3717 [, [External =>] EXTERNAL_SYMBOL]
3718 [, [Parameter_Types =>] PARAMETER_TYPES]
3719 [, [Mechanism =>] MECHANISM]
3720 [, [First_Optional_Parameter =>] IDENTIFIER]);
3721
3722 EXTERNAL_SYMBOL ::=
3723 IDENTIFIER
3724 | static_string_EXPRESSION
3725
3726 PARAMETER_TYPES ::=
3727 null
3728 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3729
3730 TYPE_DESIGNATOR ::=
3731 subtype_NAME
3732 | subtype_Name ' Access
3733
3734 MECHANISM ::=
3735 MECHANISM_NAME
3736 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3737
3738 MECHANISM_ASSOCIATION ::=
3739 [formal_parameter_NAME =>] MECHANISM_NAME
3740
3741 MECHANISM_NAME ::=
3742 Value
3743 | Reference
3744 | Descriptor [([Class =>] CLASS_NAME)]
3745 | Short_Descriptor [([Class =>] CLASS_NAME)]
3746
3747 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3748 @end smallexample
3749
3750 @noindent
3751 This pragma is identical to @code{Import_Function} except that it
3752 applies to a procedure rather than a function and the parameters
3753 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3754
3755 @node Pragma Import_Valued_Procedure
3756 @unnumberedsec Pragma Import_Valued_Procedure
3757 @findex Import_Valued_Procedure
3758 @noindent
3759 Syntax:
3760
3761 @smallexample @c ada
3762 pragma Import_Valued_Procedure (
3763 [Internal =>] LOCAL_NAME
3764 [, [External =>] EXTERNAL_SYMBOL]
3765 [, [Parameter_Types =>] PARAMETER_TYPES]
3766 [, [Mechanism =>] MECHANISM]
3767 [, [First_Optional_Parameter =>] IDENTIFIER]);
3768
3769 EXTERNAL_SYMBOL ::=
3770 IDENTIFIER
3771 | static_string_EXPRESSION
3772
3773 PARAMETER_TYPES ::=
3774 null
3775 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3776
3777 TYPE_DESIGNATOR ::=
3778 subtype_NAME
3779 | subtype_Name ' Access
3780
3781 MECHANISM ::=
3782 MECHANISM_NAME
3783 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3784
3785 MECHANISM_ASSOCIATION ::=
3786 [formal_parameter_NAME =>] MECHANISM_NAME
3787
3788 MECHANISM_NAME ::=
3789 Value
3790 | Reference
3791 | Descriptor [([Class =>] CLASS_NAME)]
3792 | Short_Descriptor [([Class =>] CLASS_NAME)]
3793
3794 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3795 @end smallexample
3796
3797 @noindent
3798 This pragma is identical to @code{Import_Procedure} except that the
3799 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3800 mode @code{OUT}, and externally the subprogram is treated as a function
3801 with this parameter as the result of the function. The purpose of this
3802 capability is to allow the use of @code{OUT} and @code{IN OUT}
3803 parameters in interfacing to external functions (which are not permitted
3804 in Ada functions). You may optionally use the @code{Mechanism}
3805 parameters to specify passing mechanisms for the parameters.
3806 If you specify a single mechanism name, it applies to all parameters.
3807 Otherwise you may specify a mechanism on a parameter by parameter
3808 basis using either positional or named notation. If the mechanism is not
3809 specified, the default mechanism is used.
3810
3811 Note that it is important to use this pragma in conjunction with a separate
3812 pragma Import that specifies the desired convention, since otherwise the
3813 default convention is Ada, which is almost certainly not what is required.
3814
3815 @node Pragma Independent
3816 @unnumberedsec Pragma Independent
3817 @findex Independent
3818 @noindent
3819 Syntax:
3820
3821 @smallexample @c ada
3822 pragma Independent (Local_NAME);
3823 @end smallexample
3824
3825 @noindent
3826 This pragma is standard in Ada 2012 mode (which also provides an aspect
3827 of the same name). It is also available as an implementation-defined
3828 pragma in all earlier versions. It specifies that the
3829 designated object or all objects of the designated type must be
3830 independently addressable. This means that separate tasks can safely
3831 manipulate such objects. For example, if two components of a record are
3832 independent, then two separate tasks may access these two components.
3833 This may place
3834 constraints on the representation of the object (for instance prohibiting
3835 tight packing).
3836
3837 @node Pragma Independent_Components
3838 @unnumberedsec Pragma Independent_Components
3839 @findex Independent_Components
3840 @noindent
3841 Syntax:
3842
3843 @smallexample @c ada
3844 pragma Independent_Components (Local_NAME);
3845 @end smallexample
3846
3847 @noindent
3848 This pragma is standard in Ada 2012 mode (which also provides an aspect
3849 of the same name). It is also available as an implementation-defined
3850 pragma in all earlier versions. It specifies that the components of the
3851 designated object, or the components of each object of the designated
3852 type, must be
3853 independently addressable. This means that separate tasks can safely
3854 manipulate separate components in the composite object. This may place
3855 constraints on the representation of the object (for instance prohibiting
3856 tight packing).
3857
3858 @node Pragma Initial_Condition
3859 @unnumberedsec Pragma Initial_Condition
3860 @findex Initial_Condition
3861 @noindent
3862 For the description of this pragma, see SPARK 2014 Reference Manual,
3863 section 7.1.6.
3864
3865 @node Pragma Initialize_Scalars
3866 @unnumberedsec Pragma Initialize_Scalars
3867 @findex Initialize_Scalars
3868 @cindex debugging with Initialize_Scalars
3869 @noindent
3870 Syntax:
3871
3872 @smallexample @c ada
3873 pragma Initialize_Scalars;
3874 @end smallexample
3875
3876 @noindent
3877 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3878 two important differences. First, there is no requirement for the pragma
3879 to be used uniformly in all units of a partition, in particular, it is fine
3880 to use this just for some or all of the application units of a partition,
3881 without needing to recompile the run-time library.
3882
3883 In the case where some units are compiled with the pragma, and some without,
3884 then a declaration of a variable where the type is defined in package
3885 Standard or is locally declared will always be subject to initialization,
3886 as will any declaration of a scalar variable. For composite variables,
3887 whether the variable is initialized may also depend on whether the package
3888 in which the type of the variable is declared is compiled with the pragma.
3889
3890 The other important difference is that you can control the value used
3891 for initializing scalar objects. At bind time, you can select several
3892 options for initialization. You can
3893 initialize with invalid values (similar to Normalize_Scalars, though for
3894 Initialize_Scalars it is not always possible to determine the invalid
3895 values in complex cases like signed component fields with non-standard
3896 sizes). You can also initialize with high or
3897 low values, or with a specified bit pattern. See the @value{EDITION}
3898 User's Guide for binder options for specifying these cases.
3899
3900 This means that you can compile a program, and then without having to
3901 recompile the program, you can run it with different values being used
3902 for initializing otherwise uninitialized values, to test if your program
3903 behavior depends on the choice. Of course the behavior should not change,
3904 and if it does, then most likely you have an incorrect reference to an
3905 uninitialized value.
3906
3907 It is even possible to change the value at execution time eliminating even
3908 the need to rebind with a different switch using an environment variable.
3909 See the @value{EDITION} User's Guide for details.
3910
3911 Note that pragma @code{Initialize_Scalars} is particularly useful in
3912 conjunction with the enhanced validity checking that is now provided
3913 in GNAT, which checks for invalid values under more conditions.
3914 Using this feature (see description of the @option{-gnatV} flag in the
3915 @value{EDITION} User's Guide) in conjunction with
3916 pragma @code{Initialize_Scalars}
3917 provides a powerful new tool to assist in the detection of problems
3918 caused by uninitialized variables.
3919
3920 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3921 effect on the generated code. This may cause your code to be
3922 substantially larger. It may also cause an increase in the amount
3923 of stack required, so it is probably a good idea to turn on stack
3924 checking (see description of stack checking in the @value{EDITION}
3925 User's Guide) when using this pragma.
3926
3927 @node Pragma Initializes
3928 @unnumberedsec Pragma Initializes
3929 @findex Initializes
3930 @noindent
3931 For the description of this pragma, see SPARK 2014 Reference Manual,
3932 section 7.1.5.
3933
3934 @node Pragma Inline_Always
3935 @unnumberedsec Pragma Inline_Always
3936 @findex Inline_Always
3937 @noindent
3938 Syntax:
3939
3940 @smallexample @c ada
3941 pragma Inline_Always (NAME [, NAME]);
3942 @end smallexample
3943
3944 @noindent
3945 Similar to pragma @code{Inline} except that inlining is not subject to
3946 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3947 happens regardless of whether these options are used.
3948
3949 @node Pragma Inline_Generic
3950 @unnumberedsec Pragma Inline_Generic
3951 @findex Inline_Generic
3952 @noindent
3953 Syntax:
3954
3955 @smallexample @c ada
3956 pragma Inline_Generic (GNAME @{, GNAME@});
3957
3958 GNAME ::= generic_unit_NAME | generic_instance_NAME
3959 @end smallexample
3960
3961 @noindent
3962 This pragma is provided for compatibility with Dec Ada 83. It has
3963 no effect in @code{GNAT} (which always inlines generics), other
3964 than to check that the given names are all names of generic units or
3965 generic instances.
3966
3967 @node Pragma Interface
3968 @unnumberedsec Pragma Interface
3969 @findex Interface
3970 @noindent
3971 Syntax:
3972
3973 @smallexample @c ada
3974 pragma Interface (
3975 [Convention =>] convention_identifier,
3976 [Entity =>] local_NAME
3977 [, [External_Name =>] static_string_expression]
3978 [, [Link_Name =>] static_string_expression]);
3979 @end smallexample
3980
3981 @noindent
3982 This pragma is identical in syntax and semantics to
3983 the standard Ada pragma @code{Import}. It is provided for compatibility
3984 with Ada 83. The definition is upwards compatible both with pragma
3985 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3986 with some extended implementations of this pragma in certain Ada 83
3987 implementations. The only difference between pragma @code{Interface}
3988 and pragma @code{Import} is that there is special circuitry to allow
3989 both pragmas to appear for the same subprogram entity (normally it
3990 is illegal to have multiple @code{Import} pragmas. This is useful in
3991 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3992 Ada 83 compilers.
3993
3994 @node Pragma Interface_Name
3995 @unnumberedsec Pragma Interface_Name
3996 @findex Interface_Name
3997 @noindent
3998 Syntax:
3999
4000 @smallexample @c ada
4001 pragma Interface_Name (
4002 [Entity =>] LOCAL_NAME
4003 [, [External_Name =>] static_string_EXPRESSION]
4004 [, [Link_Name =>] static_string_EXPRESSION]);
4005 @end smallexample
4006
4007 @noindent
4008 This pragma provides an alternative way of specifying the interface name
4009 for an interfaced subprogram, and is provided for compatibility with Ada
4010 83 compilers that use the pragma for this purpose. You must provide at
4011 least one of @var{External_Name} or @var{Link_Name}.
4012
4013 @node Pragma Interrupt_Handler
4014 @unnumberedsec Pragma Interrupt_Handler
4015 @findex Interrupt_Handler
4016 @noindent
4017 Syntax:
4018
4019 @smallexample @c ada
4020 pragma Interrupt_Handler (procedure_LOCAL_NAME);
4021 @end smallexample
4022
4023 @noindent
4024 This program unit pragma is supported for parameterless protected procedures
4025 as described in Annex C of the Ada Reference Manual. On the AAMP target
4026 the pragma can also be specified for nonprotected parameterless procedures
4027 that are declared at the library level (which includes procedures
4028 declared at the top level of a library package). In the case of AAMP,
4029 when this pragma is applied to a nonprotected procedure, the instruction
4030 @code{IERET} is generated for returns from the procedure, enabling
4031 maskable interrupts, in place of the normal return instruction.
4032
4033 @node Pragma Interrupt_State
4034 @unnumberedsec Pragma Interrupt_State
4035 @findex Interrupt_State
4036 @noindent
4037 Syntax:
4038
4039 @smallexample @c ada
4040 pragma Interrupt_State
4041 ([Name =>] value,
4042 [State =>] SYSTEM | RUNTIME | USER);
4043 @end smallexample
4044
4045 @noindent
4046 Normally certain interrupts are reserved to the implementation. Any attempt
4047 to attach an interrupt causes Program_Error to be raised, as described in
4048 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4049 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
4050 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4051 interrupt execution. Additionally, signals such as @code{SIGSEGV},
4052 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
4053 Ada exceptions, or used to implement run-time functions such as the
4054 @code{abort} statement and stack overflow checking.
4055
4056 Pragma @code{Interrupt_State} provides a general mechanism for overriding
4057 such uses of interrupts. It subsumes the functionality of pragma
4058 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
4059 available on Windows or VMS. On all other platforms than VxWorks,
4060 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
4061 and may be used to mark interrupts required by the board support package
4062 as reserved.
4063
4064 Interrupts can be in one of three states:
4065 @itemize @bullet
4066 @item System
4067
4068 The interrupt is reserved (no Ada handler can be installed), and the
4069 Ada run-time may not install a handler. As a result you are guaranteed
4070 standard system default action if this interrupt is raised.
4071
4072 @item Runtime
4073
4074 The interrupt is reserved (no Ada handler can be installed). The run time
4075 is allowed to install a handler for internal control purposes, but is
4076 not required to do so.
4077
4078 @item User
4079
4080 The interrupt is unreserved. The user may install a handler to provide
4081 some other action.
4082 @end itemize
4083
4084 @noindent
4085 These states are the allowed values of the @code{State} parameter of the
4086 pragma. The @code{Name} parameter is a value of the type
4087 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
4088 @code{Ada.Interrupts.Names}.
4089
4090 This is a configuration pragma, and the binder will check that there
4091 are no inconsistencies between different units in a partition in how a
4092 given interrupt is specified. It may appear anywhere a pragma is legal.
4093
4094 The effect is to move the interrupt to the specified state.
4095
4096 By declaring interrupts to be SYSTEM, you guarantee the standard system
4097 action, such as a core dump.
4098
4099 By declaring interrupts to be USER, you guarantee that you can install
4100 a handler.
4101
4102 Note that certain signals on many operating systems cannot be caught and
4103 handled by applications. In such cases, the pragma is ignored. See the
4104 operating system documentation, or the value of the array @code{Reserved}
4105 declared in the spec of package @code{System.OS_Interface}.
4106
4107 Overriding the default state of signals used by the Ada runtime may interfere
4108 with an application's runtime behavior in the cases of the synchronous signals,
4109 and in the case of the signal used to implement the @code{abort} statement.
4110
4111 @node Pragma Invariant
4112 @unnumberedsec Pragma Invariant
4113 @findex Invariant
4114 @noindent
4115 Syntax:
4116
4117 @smallexample @c ada
4118 pragma Invariant
4119 ([Entity =>] private_type_LOCAL_NAME,
4120 [Check =>] EXPRESSION
4121 [,[Message =>] String_Expression]);
4122 @end smallexample
4123
4124 @noindent
4125 This pragma provides exactly the same capabilities as the Type_Invariant aspect
4126 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
4127 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
4128 requires the use of the aspect syntax, which is not available except in 2012
4129 mode, it is not possible to use the Type_Invariant aspect in earlier versions
4130 of Ada. However the Invariant pragma may be used in any version of Ada. Also
4131 note that the aspect Invariant is a synonym in GNAT for the aspect
4132 Type_Invariant, but there is no pragma Type_Invariant.
4133
4134 The pragma must appear within the visible part of the package specification,
4135 after the type to which its Entity argument appears. As with the Invariant
4136 aspect, the Check expression is not analyzed until the end of the visible
4137 part of the package, so it may contain forward references. The Message
4138 argument, if present, provides the exception message used if the invariant
4139 is violated. If no Message parameter is provided, a default message that
4140 identifies the line on which the pragma appears is used.
4141
4142 It is permissible to have multiple Invariants for the same type entity, in
4143 which case they are and'ed together. It is permissible to use this pragma
4144 in Ada 2012 mode, but you cannot have both an invariant aspect and an
4145 invariant pragma for the same entity.
4146
4147 For further details on the use of this pragma, see the Ada 2012 documentation
4148 of the Type_Invariant aspect.
4149
4150 @node Pragma Java_Constructor
4151 @unnumberedsec Pragma Java_Constructor
4152 @findex Java_Constructor
4153 @noindent
4154 Syntax:
4155
4156 @smallexample @c ada
4157 pragma Java_Constructor ([Entity =>] function_LOCAL_NAME);
4158 @end smallexample
4159
4160 @noindent
4161 This pragma is used to assert that the specified Ada function should be
4162 mapped to the Java constructor for some Ada tagged record type.
4163
4164 See section 7.3.2 of the
4165 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4166 for related information.
4167
4168 @node Pragma Java_Interface
4169 @unnumberedsec Pragma Java_Interface
4170 @findex Java_Interface
4171 @noindent
4172 Syntax:
4173
4174 @smallexample @c ada
4175 pragma Java_Interface ([Entity =>] abstract_tagged_type_LOCAL_NAME);
4176 @end smallexample
4177
4178 @noindent
4179 This pragma is used to assert that the specified Ada abstract tagged type
4180 is to be mapped to a Java interface name.
4181
4182 See sections 7.1 and 7.2 of the
4183 @code{GNAT User's Guide: Supplement for the JVM Platform.}
4184 for related information.
4185
4186 @node Pragma Keep_Names
4187 @unnumberedsec Pragma Keep_Names
4188 @findex Keep_Names
4189 @noindent
4190 Syntax:
4191
4192 @smallexample @c ada
4193 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4194 @end smallexample
4195
4196 @noindent
4197 The @var{LOCAL_NAME} argument
4198 must refer to an enumeration first subtype
4199 in the current declarative part. The effect is to retain the enumeration
4200 literal names for use by @code{Image} and @code{Value} even if a global
4201 @code{Discard_Names} pragma applies. This is useful when you want to
4202 generally suppress enumeration literal names and for example you therefore
4203 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
4204 want to retain the names for specific enumeration types.
4205
4206 @node Pragma License
4207 @unnumberedsec Pragma License
4208 @findex License
4209 @cindex License checking
4210 @noindent
4211 Syntax:
4212
4213 @smallexample @c ada
4214 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4215 @end smallexample
4216
4217 @noindent
4218 This pragma is provided to allow automated checking for appropriate license
4219 conditions with respect to the standard and modified GPL@. A pragma
4220 @code{License}, which is a configuration pragma that typically appears at
4221 the start of a source file or in a separate @file{gnat.adc} file, specifies
4222 the licensing conditions of a unit as follows:
4223
4224 @itemize @bullet
4225 @item Unrestricted
4226 This is used for a unit that can be freely used with no license restrictions.
4227 Examples of such units are public domain units, and units from the Ada
4228 Reference Manual.
4229
4230 @item GPL
4231 This is used for a unit that is licensed under the unmodified GPL, and which
4232 therefore cannot be @code{with}'ed by a restricted unit.
4233
4234 @item Modified_GPL
4235 This is used for a unit licensed under the GNAT modified GPL that includes
4236 a special exception paragraph that specifically permits the inclusion of
4237 the unit in programs without requiring the entire program to be released
4238 under the GPL@.
4239
4240 @item Restricted
4241 This is used for a unit that is restricted in that it is not permitted to
4242 depend on units that are licensed under the GPL@. Typical examples are
4243 proprietary code that is to be released under more restrictive license
4244 conditions. Note that restricted units are permitted to @code{with} units
4245 which are licensed under the modified GPL (this is the whole point of the
4246 modified GPL).
4247
4248 @end itemize
4249
4250 @noindent
4251 Normally a unit with no @code{License} pragma is considered to have an
4252 unknown license, and no checking is done. However, standard GNAT headers
4253 are recognized, and license information is derived from them as follows.
4254
4255 A GNAT license header starts with a line containing 78 hyphens. The following
4256 comment text is searched for the appearance of any of the following strings.
4257
4258 If the string ``GNU General Public License'' is found, then the unit is assumed
4259 to have GPL license, unless the string ``As a special exception'' follows, in
4260 which case the license is assumed to be modified GPL@.
4261
4262 If one of the strings
4263 ``This specification is adapted from the Ada Semantic Interface'' or
4264 ``This specification is derived from the Ada Reference Manual'' is found
4265 then the unit is assumed to be unrestricted.
4266
4267 @noindent
4268 These default actions means that a program with a restricted license pragma
4269 will automatically get warnings if a GPL unit is inappropriately
4270 @code{with}'ed. For example, the program:
4271
4272 @smallexample @c ada
4273 with Sem_Ch3;
4274 with GNAT.Sockets;
4275 procedure Secret_Stuff is
4276 @dots{}
4277 end Secret_Stuff
4278 @end smallexample
4279
4280 @noindent
4281 if compiled with pragma @code{License} (@code{Restricted}) in a
4282 @file{gnat.adc} file will generate the warning:
4283
4284 @smallexample
4285 1. with Sem_Ch3;
4286 |
4287 >>> license of withed unit "Sem_Ch3" is incompatible
4288
4289 2. with GNAT.Sockets;
4290 3. procedure Secret_Stuff is
4291 @end smallexample
4292
4293 @noindent
4294 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4295 compiler and is licensed under the
4296 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4297 run time, and is therefore licensed under the modified GPL@.
4298
4299 @node Pragma Link_With
4300 @unnumberedsec Pragma Link_With
4301 @findex Link_With
4302 @noindent
4303 Syntax:
4304
4305 @smallexample @c ada
4306 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4307 @end smallexample
4308
4309 @noindent
4310 This pragma is provided for compatibility with certain Ada 83 compilers.
4311 It has exactly the same effect as pragma @code{Linker_Options} except
4312 that spaces occurring within one of the string expressions are treated
4313 as separators. For example, in the following case:
4314
4315 @smallexample @c ada
4316 pragma Link_With ("-labc -ldef");
4317 @end smallexample
4318
4319 @noindent
4320 results in passing the strings @code{-labc} and @code{-ldef} as two
4321 separate arguments to the linker. In addition pragma Link_With allows
4322 multiple arguments, with the same effect as successive pragmas.
4323
4324 @node Pragma Linker_Alias
4325 @unnumberedsec Pragma Linker_Alias
4326 @findex Linker_Alias
4327 @noindent
4328 Syntax:
4329
4330 @smallexample @c ada
4331 pragma Linker_Alias (
4332 [Entity =>] LOCAL_NAME,
4333 [Target =>] static_string_EXPRESSION);
4334 @end smallexample
4335
4336 @noindent
4337 @var{LOCAL_NAME} must refer to an object that is declared at the library
4338 level. This pragma establishes the given entity as a linker alias for the
4339 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4340 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
4341 @var{static_string_EXPRESSION} in the object file, that is to say no space
4342 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
4343 to the same address as @var{static_string_EXPRESSION} by the linker.
4344
4345 The actual linker name for the target must be used (e.g.@: the fully
4346 encoded name with qualification in Ada, or the mangled name in C++),
4347 or it must be declared using the C convention with @code{pragma Import}
4348 or @code{pragma Export}.
4349
4350 Not all target machines support this pragma. On some of them it is accepted
4351 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
4352
4353 @smallexample @c ada
4354 -- Example of the use of pragma Linker_Alias
4355
4356 package p is
4357 i : Integer := 1;
4358 pragma Export (C, i);
4359
4360 new_name_for_i : Integer;
4361 pragma Linker_Alias (new_name_for_i, "i");
4362 end p;
4363 @end smallexample
4364
4365 @node Pragma Linker_Constructor
4366 @unnumberedsec Pragma Linker_Constructor
4367 @findex Linker_Constructor
4368 @noindent
4369 Syntax:
4370
4371 @smallexample @c ada
4372 pragma Linker_Constructor (procedure_LOCAL_NAME);
4373 @end smallexample
4374
4375 @noindent
4376 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4377 is declared at the library level. A procedure to which this pragma is
4378 applied will be treated as an initialization routine by the linker.
4379 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4380 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
4381 of the executable is called (or immediately after the shared library is
4382 loaded if the procedure is linked in a shared library), in particular
4383 before the Ada run-time environment is set up.
4384
4385 Because of these specific contexts, the set of operations such a procedure
4386 can perform is very limited and the type of objects it can manipulate is
4387 essentially restricted to the elementary types. In particular, it must only
4388 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4389
4390 This pragma is used by GNAT to implement auto-initialization of shared Stand
4391 Alone Libraries, which provides a related capability without the restrictions
4392 listed above. Where possible, the use of Stand Alone Libraries is preferable
4393 to the use of this pragma.
4394
4395 @node Pragma Linker_Destructor
4396 @unnumberedsec Pragma Linker_Destructor
4397 @findex Linker_Destructor
4398 @noindent
4399 Syntax:
4400
4401 @smallexample @c ada
4402 pragma Linker_Destructor (procedure_LOCAL_NAME);
4403 @end smallexample
4404
4405 @noindent
4406 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4407 is declared at the library level. A procedure to which this pragma is
4408 applied will be treated as a finalization routine by the linker.
4409 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4410 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
4411 of the executable has exited (or immediately before the shared library
4412 is unloaded if the procedure is linked in a shared library), in particular
4413 after the Ada run-time environment is shut down.
4414
4415 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4416 because of these specific contexts.
4417
4418 @node Pragma Linker_Section
4419 @unnumberedsec Pragma Linker_Section
4420 @findex Linker_Section
4421 @noindent
4422 Syntax:
4423
4424 @smallexample @c ada
4425 pragma Linker_Section (
4426 [Entity =>] LOCAL_NAME,
4427 [Section =>] static_string_EXPRESSION);
4428 @end smallexample
4429
4430 @noindent
4431 @var{LOCAL_NAME} must refer to an object, type, or subprogram that is
4432 declared at the library level. This pragma specifies the name of the
4433 linker section for the given entity. It is equivalent to
4434 @code{__attribute__((section))} in GNU C and causes @var{LOCAL_NAME} to
4435 be placed in the @var{static_string_EXPRESSION} section of the
4436 executable (assuming the linker doesn't rename the section).
4437 GNAT also provides an implementation defined aspect of the same name.
4438
4439 In the case of specifying this aspect for a type, the effect is to
4440 specify the corresponding for all library level objects of the type which
4441 do not have an explicit linker section set. Note that this only applies to
4442 whole objects, not to components of composite objects.
4443
4444 In the case of a subprogram, the linker section applies to all previously
4445 declared matching overloaded subprograms in the current declarative part
4446 which do not already have a linker section assigned. The linker section
4447 aspect is useful in this case for specifying different linker sections
4448 for different elements of such an overloaded set.
4449
4450 Note that an empty string specifies that no linker section is specified.
4451 This is not quite the same as omitting the pragma or aspect, since it
4452 can be used to specify that one element of an overloaded set of subprograms
4453 has the default linker section, or that one object of a type for which a
4454 linker section is specified should has the default linker section.
4455
4456 The compiler normally places library-level entities in standard sections
4457 depending on the class: procedures and functions generally go in the
4458 @code{.text} section, initialized variables in the @code{.data} section
4459 and uninitialized variables in the @code{.bss} section.
4460
4461 Other, special sections may exist on given target machines to map special
4462 hardware, for example I/O ports or flash memory. This pragma is a means to
4463 defer the final layout of the executable to the linker, thus fully working
4464 at the symbolic level with the compiler.
4465
4466 Some file formats do not support arbitrary sections so not all target
4467 machines support this pragma. The use of this pragma may cause a program
4468 execution to be erroneous if it is used to place an entity into an
4469 inappropriate section (e.g.@: a modified variable into the @code{.text}
4470 section). See also @code{pragma Persistent_BSS}.
4471
4472 @smallexample @c ada
4473 -- Example of the use of pragma Linker_Section
4474
4475 package IO_Card is
4476 Port_A : Integer;
4477 pragma Volatile (Port_A);
4478 pragma Linker_Section (Port_A, ".bss.port_a");
4479
4480 Port_B : Integer;
4481 pragma Volatile (Port_B);
4482 pragma Linker_Section (Port_B, ".bss.port_b");
4483
4484 type Port_Type is new Integer with Linker_Section => ".bss";
4485 PA : Port_Type with Linker_Section => ".bss.PA";
4486 PB : Port_Type; -- ends up in linker section ".bss"
4487
4488 procedure Q with Linker_Section => "Qsection";
4489 end IO_Card;
4490 @end smallexample
4491
4492 @node Pragma Lock_Free
4493 @unnumberedsec Pragma Lock_Free
4494 @findex Lock_Free
4495 @noindent
4496 Syntax:
4497 This pragma may be specified for protected types or objects. It specifies that
4498 the implementation of protected operations must be implemented without locks.
4499 Compilation fails if the compiler cannot generate lock-free code for the
4500 operations.
4501
4502 @node Pragma Long_Float
4503 @unnumberedsec Pragma Long_Float
4504 @cindex OpenVMS
4505 @findex Long_Float
4506 @noindent
4507 Syntax:
4508
4509 @smallexample @c ada
4510 pragma Long_Float (FLOAT_FORMAT);
4511
4512 FLOAT_FORMAT ::= D_Float | G_Float
4513 @end smallexample
4514
4515 @noindent
4516 This pragma is implemented only in the OpenVMS implementation of GNAT@.
4517 It allows control over the internal representation chosen for the predefined
4518 type @code{Long_Float} and for floating point type representations with
4519 @code{digits} specified in the range 7 through 15.
4520 For further details on this pragma, see the
4521 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
4522 this pragma, the standard runtime libraries must be recompiled.
4523
4524 @node Pragma Loop_Invariant
4525 @unnumberedsec Pragma Loop_Invariant
4526 @findex Loop_Invariant
4527 @noindent
4528 Syntax:
4529
4530 @smallexample @c ada
4531 pragma Loop_Invariant ( boolean_EXPRESSION );
4532 @end smallexample
4533
4534 @noindent
4535 The effect of this pragma is similar to that of pragma @code{Assert},
4536 except that in an @code{Assertion_Policy} pragma, the identifier
4537 @code{Loop_Invariant} is used to control whether it is ignored or checked
4538 (or disabled).
4539
4540 @code{Loop_Invariant} can only appear as one of the items in the sequence
4541 of statements of a loop body, or nested inside block statements that
4542 appear in the sequence of statements of a loop body.
4543 The intention is that it be used to
4544 represent a "loop invariant" assertion, i.e. something that is true each
4545 time through the loop, and which can be used to show that the loop is
4546 achieving its purpose.
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 To aid in writing such invariants, the special attribute @code{Loop_Entry}
4553 may be used to refer to the value of an expression on entry to the loop. This
4554 attribute can only be used within the expression of a @code{Loop_Invariant}
4555 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
4556
4557 @node Pragma Loop_Optimize
4558 @unnumberedsec Pragma Loop_Optimize
4559 @findex Loop_Optimize
4560 @noindent
4561 Syntax:
4562
4563 @smallexample @c ada
4564 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
4565
4566 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
4567 @end smallexample
4568
4569 @noindent
4570 This pragma must appear immediately within a loop statement. It allows the
4571 programmer to specify optimization hints for the enclosing loop. The hints
4572 are not mutually exclusive and can be freely mixed, but not all combinations
4573 will yield a sensible outcome.
4574
4575 There are five supported optimization hints for a loop:
4576
4577 @itemize @bullet
4578 @item Ivdep
4579
4580 The programmer asserts that there are no loop-carried dependencies
4581 which would prevent consecutive iterations of the loop from being
4582 executed simultaneously.
4583
4584 @item No_Unroll
4585
4586 The loop must not be unrolled. This is a strong hint: the compiler will not
4587 unroll a loop marked with this hint.
4588
4589 @item Unroll
4590
4591 The loop should be unrolled. This is a weak hint: the compiler will try to
4592 apply unrolling to this loop preferably to other optimizations, notably
4593 vectorization, but there is no guarantee that the loop will be unrolled.
4594
4595 @item No_Vector
4596
4597 The loop must not be vectorized. This is a strong hint: the compiler will not
4598 vectorize a loop marked with this hint.
4599
4600 @item Vector
4601
4602 The loop should be vectorized. This is a weak hint: the compiler will try to
4603 apply vectorization to this loop preferably to other optimizations, notably
4604 unrolling, but there is no guarantee that the loop will be vectorized.
4605
4606 @end itemize
4607
4608 These hints do not remove the need to pass the appropriate switches to the
4609 compiler in order to enable the relevant optimizations, that is to say
4610 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
4611 vectorization.
4612
4613 @node Pragma Loop_Variant
4614 @unnumberedsec Pragma Loop_Variant
4615 @findex Loop_Variant
4616 @noindent
4617 Syntax:
4618
4619 @smallexample @c ada
4620 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
4621 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
4622 CHANGE_DIRECTION ::= Increases | Decreases
4623 @end smallexample
4624
4625 @noindent
4626 @code{Loop_Variant} can only appear as one of the items in the sequence
4627 of statements of a loop body, or nested inside block statements that
4628 appear in the sequence of statements of a loop body.
4629 It allows the specification of quantities which must always
4630 decrease or increase in successive iterations of the loop. In its simplest
4631 form, just one expression is specified, whose value must increase or decrease
4632 on each iteration of the loop.
4633
4634 In a more complex form, multiple arguments can be given which are intepreted
4635 in a nesting lexicographic manner. For example:
4636
4637 @smallexample @c ada
4638 pragma Loop_Variant (Increases => X, Decreases => Y);
4639 @end smallexample
4640
4641 @noindent
4642 specifies that each time through the loop either X increases, or X stays
4643 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
4644 loop is making progress. It can be useful in helping to show informally
4645 or prove formally that the loop always terminates.
4646
4647 @code{Loop_Variant} is an assertion whose effect can be controlled using
4648 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
4649 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
4650 to ignore the check (in which case the pragma has no effect on the program),
4651 or @code{Disable} in which case the pragma is not even checked for correct
4652 syntax.
4653
4654 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
4655 apply to the same loop should be grouped in the same sequence of
4656 statements.
4657
4658 The @code{Loop_Entry} attribute may be used within the expressions of the
4659 @code{Loop_Variant} pragma to refer to values on entry to the loop.
4660
4661 @node Pragma Machine_Attribute
4662 @unnumberedsec Pragma Machine_Attribute
4663 @findex Machine_Attribute
4664 @noindent
4665 Syntax:
4666
4667 @smallexample @c ada
4668 pragma Machine_Attribute (
4669 [Entity =>] LOCAL_NAME,
4670 [Attribute_Name =>] static_string_EXPRESSION
4671 [, [Info =>] static_EXPRESSION] );
4672 @end smallexample
4673
4674 @noindent
4675 Machine-dependent attributes can be specified for types and/or
4676 declarations. This pragma is semantically equivalent to
4677 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
4678 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
4679 in GNU C, where @code{@var{attribute_name}} is recognized by the
4680 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
4681 specific macro. A string literal for the optional parameter @var{info}
4682 is transformed into an identifier, which may make this pragma unusable
4683 for some attributes. @xref{Target Attributes,, Defining target-specific
4684 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
4685 Internals}, further information.
4686
4687 @node Pragma Main
4688 @unnumberedsec Pragma Main
4689 @cindex OpenVMS
4690 @findex Main
4691 @noindent
4692 Syntax:
4693
4694 @smallexample @c ada
4695 pragma Main
4696 (MAIN_OPTION [, MAIN_OPTION]);
4697
4698 MAIN_OPTION ::=
4699 [Stack_Size =>] static_integer_EXPRESSION
4700 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
4701 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
4702 @end smallexample
4703
4704 @noindent
4705 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4706 no effect in GNAT, other than being syntax checked.
4707
4708 @node Pragma Main_Storage
4709 @unnumberedsec Pragma Main_Storage
4710 @cindex OpenVMS
4711 @findex Main_Storage
4712 @noindent
4713 Syntax:
4714
4715 @smallexample @c ada
4716 pragma Main_Storage
4717 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4718
4719 MAIN_STORAGE_OPTION ::=
4720 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4721 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
4722 @end smallexample
4723
4724 @noindent
4725 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4726 no effect in GNAT, other than being syntax checked. Note that the pragma
4727 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4728
4729 @node Pragma No_Body
4730 @unnumberedsec Pragma No_Body
4731 @findex No_Body
4732 @noindent
4733 Syntax:
4734
4735 @smallexample @c ada
4736 pragma No_Body;
4737 @end smallexample
4738
4739 @noindent
4740 There are a number of cases in which a package spec does not require a body,
4741 and in fact a body is not permitted. GNAT will not permit the spec to be
4742 compiled if there is a body around. The pragma No_Body allows you to provide
4743 a body file, even in a case where no body is allowed. The body file must
4744 contain only comments and a single No_Body pragma. This is recognized by
4745 the compiler as indicating that no body is logically present.
4746
4747 This is particularly useful during maintenance when a package is modified in
4748 such a way that a body needed before is no longer needed. The provision of a
4749 dummy body with a No_Body pragma ensures that there is no interference from
4750 earlier versions of the package body.
4751
4752 @node Pragma No_Inline
4753 @unnumberedsec Pragma No_Inline
4754 @findex No_Inline
4755 @noindent
4756 Syntax:
4757
4758 @smallexample @c ada
4759 pragma No_Inline (NAME @{, NAME@});
4760 @end smallexample
4761
4762 @noindent
4763 This pragma suppresses inlining for the callable entity or the instances of
4764 the generic subprogram designated by @var{NAME}, including inlining that
4765 results from the use of pragma @code{Inline}. This pragma is always active,
4766 in particular it is not subject to the use of option @option{-gnatn} or
4767 @option{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
4768 pragma @code{Inline_Always} for the same @var{NAME}.
4769
4770 @node Pragma No_Return
4771 @unnumberedsec Pragma No_Return
4772 @findex No_Return
4773 @noindent
4774 Syntax:
4775
4776 @smallexample @c ada
4777 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4778 @end smallexample
4779
4780 @noindent
4781 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4782 declarations in the current declarative part. A procedure to which this
4783 pragma is applied may not contain any explicit @code{return} statements.
4784 In addition, if the procedure contains any implicit returns from falling
4785 off the end of a statement sequence, then execution of that implicit
4786 return will cause Program_Error to be raised.
4787
4788 One use of this pragma is to identify procedures whose only purpose is to raise
4789 an exception. Another use of this pragma is to suppress incorrect warnings
4790 about missing returns in functions, where the last statement of a function
4791 statement sequence is a call to such a procedure.
4792
4793 Note that in Ada 2005 mode, this pragma is part of the language. It is
4794 available in all earlier versions of Ada as an implementation-defined
4795 pragma.
4796
4797 @node Pragma No_Run_Time
4798 @unnumberedsec Pragma No_Run_Time
4799 @findex No_Run_Time
4800 @noindent
4801 Syntax:
4802
4803 @smallexample @c ada
4804 pragma No_Run_Time;
4805 @end smallexample
4806
4807 @noindent
4808 This is an obsolete configuration pragma that historically was used to
4809 setup what is now called the "zero footprint" library. It causes any
4810 library units outside this basic library to be ignored. The use of
4811 this pragma has been superseded by the general configurable run-time
4812 capability of @code{GNAT} where the compiler takes into account whatever
4813 units happen to be accessible in the library.
4814
4815 @node Pragma No_Strict_Aliasing
4816 @unnumberedsec Pragma No_Strict_Aliasing
4817 @findex No_Strict_Aliasing
4818 @noindent
4819 Syntax:
4820
4821 @smallexample @c ada
4822 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4823 @end smallexample
4824
4825 @noindent
4826 @var{type_LOCAL_NAME} must refer to an access type
4827 declaration in the current declarative part. The effect is to inhibit
4828 strict aliasing optimization for the given type. The form with no
4829 arguments is a configuration pragma which applies to all access types
4830 declared in units to which the pragma applies. For a detailed
4831 description of the strict aliasing optimization, and the situations
4832 in which it must be suppressed, see @ref{Optimization and Strict
4833 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4834
4835 This pragma currently has no effects on access to unconstrained array types.
4836
4837 @node Pragma Normalize_Scalars
4838 @unnumberedsec Pragma Normalize_Scalars
4839 @findex Normalize_Scalars
4840 @noindent
4841 Syntax:
4842
4843 @smallexample @c ada
4844 pragma Normalize_Scalars;
4845 @end smallexample
4846
4847 @noindent
4848 This is a language defined pragma which is fully implemented in GNAT@. The
4849 effect is to cause all scalar objects that are not otherwise initialized
4850 to be initialized. The initial values are implementation dependent and
4851 are as follows:
4852
4853 @table @code
4854 @item Standard.Character
4855 @noindent
4856 Objects whose root type is Standard.Character are initialized to
4857 Character'Last unless the subtype range excludes NUL (in which case
4858 NUL is used). This choice will always generate an invalid value if
4859 one exists.
4860
4861 @item Standard.Wide_Character
4862 @noindent
4863 Objects whose root type is Standard.Wide_Character are initialized to
4864 Wide_Character'Last unless the subtype range excludes NUL (in which case
4865 NUL is used). This choice will always generate an invalid value if
4866 one exists.
4867
4868 @item Standard.Wide_Wide_Character
4869 @noindent
4870 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4871 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4872 which case NUL is used). This choice will always generate an invalid value if
4873 one exists.
4874
4875 @item Integer types
4876 @noindent
4877 Objects of an integer type are treated differently depending on whether
4878 negative values are present in the subtype. If no negative values are
4879 present, then all one bits is used as the initial value except in the
4880 special case where zero is excluded from the subtype, in which case
4881 all zero bits are used. This choice will always generate an invalid
4882 value if one exists.
4883
4884 For subtypes with negative values present, the largest negative number
4885 is used, except in the unusual case where this largest negative number
4886 is in the subtype, and the largest positive number is not, in which case
4887 the largest positive value is used. This choice will always generate
4888 an invalid value if one exists.
4889
4890 @item Floating-Point Types
4891 Objects of all floating-point types are initialized to all 1-bits. For
4892 standard IEEE format, this corresponds to a NaN (not a number) which is
4893 indeed an invalid value.
4894
4895 @item Fixed-Point Types
4896 Objects of all fixed-point types are treated as described above for integers,
4897 with the rules applying to the underlying integer value used to represent
4898 the fixed-point value.
4899
4900 @item Modular types
4901 Objects of a modular type are initialized to all one bits, except in
4902 the special case where zero is excluded from the subtype, in which
4903 case all zero bits are used. This choice will always generate an
4904 invalid value if one exists.
4905
4906 @item Enumeration types
4907 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4908 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4909 whose Pos value is zero, in which case a code of zero is used. This choice
4910 will always generate an invalid value if one exists.
4911
4912 @end table
4913
4914 @node Pragma Obsolescent
4915 @unnumberedsec Pragma Obsolescent
4916 @findex Obsolescent
4917 @noindent
4918 Syntax:
4919
4920 @smallexample @c ada
4921 pragma Obsolescent;
4922
4923 pragma Obsolescent (
4924 [Message =>] static_string_EXPRESSION
4925 [,[Version =>] Ada_05]]);
4926
4927 pragma Obsolescent (
4928 [Entity =>] NAME
4929 [,[Message =>] static_string_EXPRESSION
4930 [,[Version =>] Ada_05]] );
4931 @end smallexample
4932
4933 @noindent
4934 This pragma can occur immediately following a declaration of an entity,
4935 including the case of a record component. If no Entity argument is present,
4936 then this declaration is the one to which the pragma applies. If an Entity
4937 parameter is present, it must either match the name of the entity in this
4938 declaration, or alternatively, the pragma can immediately follow an enumeration
4939 type declaration, where the Entity argument names one of the enumeration
4940 literals.
4941
4942 This pragma is used to indicate that the named entity
4943 is considered obsolescent and should not be used. Typically this is
4944 used when an API must be modified by eventually removing or modifying
4945 existing subprograms or other entities. The pragma can be used at an
4946 intermediate stage when the entity is still present, but will be
4947 removed later.
4948
4949 The effect of this pragma is to output a warning message on a reference to
4950 an entity thus marked that the subprogram is obsolescent if the appropriate
4951 warning option in the compiler is activated. If the Message parameter is
4952 present, then a second warning message is given containing this text. In
4953 addition, a reference to the entity is considered to be a violation of pragma
4954 Restrictions (No_Obsolescent_Features).
4955
4956 This pragma can also be used as a program unit pragma for a package,
4957 in which case the entity name is the name of the package, and the
4958 pragma indicates that the entire package is considered
4959 obsolescent. In this case a client @code{with}'ing such a package
4960 violates the restriction, and the @code{with} statement is
4961 flagged with warnings if the warning option is set.
4962
4963 If the Version parameter is present (which must be exactly
4964 the identifier Ada_05, no other argument is allowed), then the
4965 indication of obsolescence applies only when compiling in Ada 2005
4966 mode. This is primarily intended for dealing with the situations
4967 in the predefined library where subprograms or packages
4968 have become defined as obsolescent in Ada 2005
4969 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4970
4971 The following examples show typical uses of this pragma:
4972
4973 @smallexample @c ada
4974 package p is
4975 pragma Obsolescent (p, Message => "use pp instead of p");
4976 end p;
4977
4978 package q is
4979 procedure q2;
4980 pragma Obsolescent ("use q2new instead");
4981
4982 type R is new integer;
4983 pragma Obsolescent
4984 (Entity => R,
4985 Message => "use RR in Ada 2005",
4986 Version => Ada_05);
4987
4988 type M is record
4989 F1 : Integer;
4990 F2 : Integer;
4991 pragma Obsolescent;
4992 F3 : Integer;
4993 end record;
4994
4995 type E is (a, bc, 'd', quack);
4996 pragma Obsolescent (Entity => bc)
4997 pragma Obsolescent (Entity => 'd')
4998
4999 function "+"
5000 (a, b : character) return character;
5001 pragma Obsolescent (Entity => "+");
5002 end;
5003 @end smallexample
5004
5005 @noindent
5006 Note that, as for all pragmas, if you use a pragma argument identifier,
5007 then all subsequent parameters must also use a pragma argument identifier.
5008 So if you specify "Entity =>" for the Entity argument, and a Message
5009 argument is present, it must be preceded by "Message =>".
5010
5011 @node Pragma Optimize_Alignment
5012 @unnumberedsec Pragma Optimize_Alignment
5013 @findex Optimize_Alignment
5014 @cindex Alignment, default settings
5015 @noindent
5016 Syntax:
5017
5018 @smallexample @c ada
5019 pragma Optimize_Alignment (TIME | SPACE | OFF);
5020 @end smallexample
5021
5022 @noindent
5023 This is a configuration pragma which affects the choice of default alignments
5024 for types and objects where no alignment is explicitly specified. There is a
5025 time/space trade-off in the selection of these values. Large alignments result
5026 in more efficient code, at the expense of larger data space, since sizes have
5027 to be increased to match these alignments. Smaller alignments save space, but
5028 the access code is slower. The normal choice of default alignments for types
5029 and individual alignment promotions for objects (which is what you get if you
5030 do not use this pragma, or if you use an argument of OFF), tries to balance
5031 these two requirements.
5032
5033 Specifying SPACE causes smaller default alignments to be chosen in two cases.
5034 First any packed record is given an alignment of 1. Second, if a size is given
5035 for the type, then the alignment is chosen to avoid increasing this size. For
5036 example, consider:
5037
5038 @smallexample @c ada
5039 type R is record
5040 X : Integer;
5041 Y : Character;
5042 end record;
5043
5044 for R'Size use 5*8;
5045 @end smallexample
5046
5047 @noindent
5048 In the default mode, this type gets an alignment of 4, so that access to the
5049 Integer field X are efficient. But this means that objects of the type end up
5050 with a size of 8 bytes. This is a valid choice, since sizes of objects are
5051 allowed to be bigger than the size of the type, but it can waste space if for
5052 example fields of type R appear in an enclosing record. If the above type is
5053 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
5054
5055 However, there is one case in which SPACE is ignored. If a variable length
5056 record (that is a discriminated record with a component which is an array
5057 whose length depends on a discriminant), has a pragma Pack, then it is not
5058 in general possible to set the alignment of such a record to one, so the
5059 pragma is ignored in this case (with a warning).
5060
5061 Specifying SPACE also disables alignment promotions for standalone objects,
5062 which occur when the compiler increases the alignment of a specific object
5063 without changing the alignment of its type.
5064
5065 Specifying TIME causes larger default alignments to be chosen in the case of
5066 small types with sizes that are not a power of 2. For example, consider:
5067
5068 @smallexample @c ada
5069 type R is record
5070 A : Character;
5071 B : Character;
5072 C : Boolean;
5073 end record;
5074
5075 pragma Pack (R);
5076 for R'Size use 17;
5077 @end smallexample
5078
5079 @noindent
5080 The default alignment for this record is normally 1, but if this type is
5081 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
5082 to 4, which wastes space for objects of the type, since they are now 4 bytes
5083 long, but results in more efficient access when the whole record is referenced.
5084
5085 As noted above, this is a configuration pragma, and there is a requirement
5086 that all units in a partition be compiled with a consistent setting of the
5087 optimization setting. This would normally be achieved by use of a configuration
5088 pragma file containing the appropriate setting. The exception to this rule is
5089 that units with an explicit configuration pragma in the same file as the source
5090 unit are excluded from the consistency check, as are all predefined units. The
5091 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
5092 pragma appears at the start of the file.
5093
5094 @node Pragma Ordered
5095 @unnumberedsec Pragma Ordered
5096 @findex Ordered
5097 @findex pragma @code{Ordered}
5098 @noindent
5099 Syntax:
5100
5101 @smallexample @c ada
5102 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
5103 @end smallexample
5104
5105 @noindent
5106 Most enumeration types are from a conceptual point of view unordered.
5107 For example, consider:
5108
5109 @smallexample @c ada
5110 type Color is (Red, Blue, Green, Yellow);
5111 @end smallexample
5112
5113 @noindent
5114 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
5115 but really these relations make no sense; the enumeration type merely
5116 specifies a set of possible colors, and the order is unimportant.
5117
5118 For unordered enumeration types, it is generally a good idea if
5119 clients avoid comparisons (other than equality or inequality) and
5120 explicit ranges. (A @emph{client} is a unit where the type is referenced,
5121 other than the unit where the type is declared, its body, and its subunits.)
5122 For example, if code buried in some client says:
5123
5124 @smallexample @c ada
5125 if Current_Color < Yellow then ...
5126 if Current_Color in Blue .. Green then ...
5127 @end smallexample
5128
5129 @noindent
5130 then the client code is relying on the order, which is undesirable.
5131 It makes the code hard to read and creates maintenance difficulties if
5132 entries have to be added to the enumeration type. Instead,
5133 the code in the client should list the possibilities, or an
5134 appropriate subtype should be declared in the unit that declares
5135 the original enumeration type. E.g., the following subtype could
5136 be declared along with the type @code{Color}:
5137
5138 @smallexample @c ada
5139 subtype RBG is Color range Red .. Green;
5140 @end smallexample
5141
5142 @noindent
5143 and then the client could write:
5144
5145 @smallexample @c ada
5146 if Current_Color in RBG then ...
5147 if Current_Color = Blue or Current_Color = Green then ...
5148 @end smallexample
5149
5150 @noindent
5151 However, some enumeration types are legitimately ordered from a conceptual
5152 point of view. For example, if you declare:
5153
5154 @smallexample @c ada
5155 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
5156 @end smallexample
5157
5158 @noindent
5159 then the ordering imposed by the language is reasonable, and
5160 clients can depend on it, writing for example:
5161
5162 @smallexample @c ada
5163 if D in Mon .. Fri then ...
5164 if D < Wed then ...
5165 @end smallexample
5166
5167 @noindent
5168 The pragma @option{Ordered} is provided to mark enumeration types that
5169 are conceptually ordered, alerting the reader that clients may depend
5170 on the ordering. GNAT provides a pragma to mark enumerations as ordered
5171 rather than one to mark them as unordered, since in our experience,
5172 the great majority of enumeration types are conceptually unordered.
5173
5174 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
5175 and @code{Wide_Wide_Character}
5176 are considered to be ordered types, so each is declared with a
5177 pragma @code{Ordered} in package @code{Standard}.
5178
5179 Normally pragma @code{Ordered} serves only as documentation and a guide for
5180 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
5181 requests warnings for inappropriate uses (comparisons and explicit
5182 subranges) for unordered types. If this switch is used, then any
5183 enumeration type not marked with pragma @code{Ordered} will be considered
5184 as unordered, and will generate warnings for inappropriate uses.
5185
5186 For additional information please refer to the description of the
5187 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
5188
5189 @node Pragma Overflow_Mode
5190 @unnumberedsec Pragma Overflow_Mode
5191 @findex Overflow checks
5192 @findex Overflow mode
5193 @findex pragma @code{Overflow_Mode}
5194 @noindent
5195 Syntax:
5196
5197 @smallexample @c ada
5198 pragma Overflow_Mode
5199 ( [General =>] MODE
5200 [,[Assertions =>] MODE]);
5201
5202 MODE ::= STRICT | MINIMIZED | ELIMINATED
5203 @end smallexample
5204
5205 @noindent
5206 This pragma sets the current overflow mode to the given setting. For details
5207 of the meaning of these modes, please refer to the
5208 ``Overflow Check Handling in GNAT'' appendix in the
5209 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
5210 the given mode applies to all expressions. If both parameters are present,
5211 the @code{General} mode applies to expressions outside assertions, and
5212 the @code{Eliminated} mode applies to expressions within assertions.
5213
5214 The case of the @code{MODE} parameter is ignored,
5215 so @code{MINIMIZED}, @code{Minimized} and
5216 @code{minimized} all have the same effect.
5217
5218 The @code{Overflow_Mode} pragma has the same scoping and placement
5219 rules as pragma @code{Suppress}, so it can occur either as a
5220 configuration pragma, specifying a default for the whole
5221 program, or in a declarative scope, where it applies to the
5222 remaining declarations and statements in that scope.
5223
5224 The pragma @code{Suppress (Overflow_Check)} suppresses
5225 overflow checking, but does not affect the overflow mode.
5226
5227 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
5228 overflow checking, but does not affect the overflow mode.
5229
5230 @node Pragma Overriding_Renamings
5231 @unnumberedsec Pragma Overriding_Renamings
5232 @findex Overriding_Renamings
5233 @cindex Rational profile
5234 @cindex Rational compatibility
5235 @noindent
5236 Syntax:
5237
5238 @smallexample @c ada
5239 pragma Overriding_Renamings;
5240 @end smallexample
5241
5242 @noindent
5243 This is a GNAT configuration pragma to simplify porting
5244 legacy code accepted by the Rational
5245 Ada compiler. In the presence of this pragma, a renaming declaration that
5246 renames an inherited operation declared in the same scope is legal if selected
5247 notation is used as in:
5248
5249 @smallexample @c ada
5250 pragma Overriding_Renamings;
5251 ...
5252 package R is
5253 function F (..);
5254 ...
5255 function F (..) renames R.F;
5256 end R;
5257 @end smallexample
5258
5259 even though
5260 RM 8.3 (15) stipulates that an overridden operation is not visible within the
5261 declaration of the overriding operation.
5262
5263 @node Pragma Partition_Elaboration_Policy
5264 @unnumberedsec Pragma Partition_Elaboration_Policy
5265 @findex Partition_Elaboration_Policy
5266 @noindent
5267 Syntax:
5268
5269 @smallexample @c ada
5270 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
5271
5272 POLICY_IDENTIFIER ::= Concurrent | Sequential
5273 @end smallexample
5274
5275 @noindent
5276 This pragma is standard in Ada 2005, but is available in all earlier
5277 versions of Ada as an implementation-defined pragma.
5278 See Ada 2012 Reference Manual for details.
5279
5280 @node Pragma Part_Of
5281 @unnumberedsec Pragma Part_Of
5282 @findex Part_Of
5283 @noindent
5284 For the description of this pragma, see SPARK 2014 Reference Manual,
5285 section 7.2.6.
5286
5287 @node Pragma Passive
5288 @unnumberedsec Pragma Passive
5289 @findex Passive
5290 @noindent
5291 Syntax:
5292
5293 @smallexample @c ada
5294 pragma Passive [(Semaphore | No)];
5295 @end smallexample
5296
5297 @noindent
5298 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
5299 compatibility with DEC Ada 83 implementations, where it is used within a
5300 task definition to request that a task be made passive. If the argument
5301 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
5302 treats the pragma as an assertion that the containing task is passive
5303 and that optimization of context switch with this task is permitted and
5304 desired. If the argument @code{No} is present, the task must not be
5305 optimized. GNAT does not attempt to optimize any tasks in this manner
5306 (since protected objects are available in place of passive tasks).
5307
5308 For more information on the subject of passive tasks, see the section
5309 ``Passive Task Optimization'' in the GNAT Users Guide.
5310
5311 @node Pragma Persistent_BSS
5312 @unnumberedsec Pragma Persistent_BSS
5313 @findex Persistent_BSS
5314 @noindent
5315 Syntax:
5316
5317 @smallexample @c ada
5318 pragma Persistent_BSS [(LOCAL_NAME)]
5319 @end smallexample
5320
5321 @noindent
5322 This pragma allows selected objects to be placed in the @code{.persistent_bss}
5323 section. On some targets the linker and loader provide for special
5324 treatment of this section, allowing a program to be reloaded without
5325 affecting the contents of this data (hence the name persistent).
5326
5327 There are two forms of usage. If an argument is given, it must be the
5328 local name of a library level object, with no explicit initialization
5329 and whose type is potentially persistent. If no argument is given, then
5330 the pragma is a configuration pragma, and applies to all library level
5331 objects with no explicit initialization of potentially persistent types.
5332
5333 A potentially persistent type is a scalar type, or an untagged,
5334 non-discriminated record, all of whose components have no explicit
5335 initialization and are themselves of a potentially persistent type,
5336 or an array, all of whose constraints are static, and whose component
5337 type is potentially persistent.
5338
5339 If this pragma is used on a target where this feature is not supported,
5340 then the pragma will be ignored. See also @code{pragma Linker_Section}.
5341
5342 @node Pragma Polling
5343 @unnumberedsec Pragma Polling
5344 @findex Polling
5345 @noindent
5346 Syntax:
5347
5348 @smallexample @c ada
5349 pragma Polling (ON | OFF);
5350 @end smallexample
5351
5352 @noindent
5353 This pragma controls the generation of polling code. This is normally off.
5354 If @code{pragma Polling (ON)} is used then periodic calls are generated to
5355 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
5356 runtime library, and can be found in file @file{a-excpol.adb}.
5357
5358 Pragma @code{Polling} can appear as a configuration pragma (for example it
5359 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
5360 can be used in the statement or declaration sequence to control polling
5361 more locally.
5362
5363 A call to the polling routine is generated at the start of every loop and
5364 at the start of every subprogram call. This guarantees that the @code{Poll}
5365 routine is called frequently, and places an upper bound (determined by
5366 the complexity of the code) on the period between two @code{Poll} calls.
5367
5368 The primary purpose of the polling interface is to enable asynchronous
5369 aborts on targets that cannot otherwise support it (for example Windows
5370 NT), but it may be used for any other purpose requiring periodic polling.
5371 The standard version is null, and can be replaced by a user program. This
5372 will require re-compilation of the @code{Ada.Exceptions} package that can
5373 be found in files @file{a-except.ads} and @file{a-except.adb}.
5374
5375 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
5376 distribution) is used to enable the asynchronous abort capability on
5377 targets that do not normally support the capability. The version of
5378 @code{Poll} in this file makes a call to the appropriate runtime routine
5379 to test for an abort condition.
5380
5381 Note that polling can also be enabled by use of the @option{-gnatP} switch.
5382 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
5383 details.
5384
5385 @node Pragma Post
5386 @unnumberedsec Pragma Post
5387 @cindex Post
5388 @cindex Checks, postconditions
5389 @findex Postconditions
5390 @noindent
5391 Syntax:
5392
5393 @smallexample @c ada
5394 pragma Post (Boolean_Expression);
5395 @end smallexample
5396
5397 @noindent
5398 The @code{Post} pragma is intended to be an exact replacement for
5399 the language-defined
5400 @code{Post} aspect, and shares its restrictions and semantics.
5401 It must appear either immediately following the corresponding
5402 subprogram declaration (only other pragmas may intervene), or
5403 if there is no separate subprogram declaration, then it can
5404 appear at the start of the declarations in a subprogram body
5405 (preceded only by other pragmas).
5406
5407 @node Pragma Postcondition
5408 @unnumberedsec Pragma Postcondition
5409 @cindex Postcondition
5410 @cindex Checks, postconditions
5411 @findex Postconditions
5412 @noindent
5413 Syntax:
5414
5415 @smallexample @c ada
5416 pragma Postcondition (
5417 [Check =>] Boolean_Expression
5418 [,[Message =>] String_Expression]);
5419 @end smallexample
5420
5421 @noindent
5422 The @code{Postcondition} pragma allows specification of automatic
5423 postcondition checks for subprograms. These checks are similar to
5424 assertions, but are automatically inserted just prior to the return
5425 statements of the subprogram with which they are associated (including
5426 implicit returns at the end of procedure bodies and associated
5427 exception handlers).
5428
5429 In addition, the boolean expression which is the condition which
5430 must be true may contain references to function'Result in the case
5431 of a function to refer to the returned value.
5432
5433 @code{Postcondition} pragmas may appear either immediately following the
5434 (separate) declaration of a subprogram, or at the start of the
5435 declarations of a subprogram body. Only other pragmas may intervene
5436 (that is appear between the subprogram declaration and its
5437 postconditions, or appear before the postcondition in the
5438 declaration sequence in a subprogram body). In the case of a
5439 postcondition appearing after a subprogram declaration, the
5440 formal arguments of the subprogram are visible, and can be
5441 referenced in the postcondition expressions.
5442
5443 The postconditions are collected and automatically tested just
5444 before any return (implicit or explicit) in the subprogram body.
5445 A postcondition is only recognized if postconditions are active
5446 at the time the pragma is encountered. The compiler switch @option{gnata}
5447 turns on all postconditions by default, and pragma @code{Check_Policy}
5448 with an identifier of @code{Postcondition} can also be used to
5449 control whether postconditions are active.
5450
5451 The general approach is that postconditions are placed in the spec
5452 if they represent functional aspects which make sense to the client.
5453 For example we might have:
5454
5455 @smallexample @c ada
5456 function Direction return Integer;
5457 pragma Postcondition
5458 (Direction'Result = +1
5459 or else
5460 Direction'Result = -1);
5461 @end smallexample
5462
5463 @noindent
5464 which serves to document that the result must be +1 or -1, and
5465 will test that this is the case at run time if postcondition
5466 checking is active.
5467
5468 Postconditions within the subprogram body can be used to
5469 check that some internal aspect of the implementation,
5470 not visible to the client, is operating as expected.
5471 For instance if a square root routine keeps an internal
5472 counter of the number of times it is called, then we
5473 might have the following postcondition:
5474
5475 @smallexample @c ada
5476 Sqrt_Calls : Natural := 0;
5477
5478 function Sqrt (Arg : Float) return Float is
5479 pragma Postcondition
5480 (Sqrt_Calls = Sqrt_Calls'Old + 1);
5481 ...
5482 end Sqrt
5483 @end smallexample
5484
5485 @noindent
5486 As this example, shows, the use of the @code{Old} attribute
5487 is often useful in postconditions to refer to the state on
5488 entry to the subprogram.
5489
5490 Note that postconditions are only checked on normal returns
5491 from the subprogram. If an abnormal return results from
5492 raising an exception, then the postconditions are not checked.
5493
5494 If a postcondition fails, then the exception
5495 @code{System.Assertions.Assert_Failure} is raised. If
5496 a message argument was supplied, then the given string
5497 will be used as the exception message. If no message
5498 argument was supplied, then the default message has
5499 the form "Postcondition failed at file:line". The
5500 exception is raised in the context of the subprogram
5501 body, so it is possible to catch postcondition failures
5502 within the subprogram body itself.
5503
5504 Within a package spec, normal visibility rules
5505 in Ada would prevent forward references within a
5506 postcondition pragma to functions defined later in
5507 the same package. This would introduce undesirable
5508 ordering constraints. To avoid this problem, all
5509 postcondition pragmas are analyzed at the end of
5510 the package spec, allowing forward references.
5511
5512 The following example shows that this even allows
5513 mutually recursive postconditions as in:
5514
5515 @smallexample @c ada
5516 package Parity_Functions is
5517 function Odd (X : Natural) return Boolean;
5518 pragma Postcondition
5519 (Odd'Result =
5520 (x = 1
5521 or else
5522 (x /= 0 and then Even (X - 1))));
5523
5524 function Even (X : Natural) return Boolean;
5525 pragma Postcondition
5526 (Even'Result =
5527 (x = 0
5528 or else
5529 (x /= 1 and then Odd (X - 1))));
5530
5531 end Parity_Functions;
5532 @end smallexample
5533
5534 @noindent
5535 There are no restrictions on the complexity or form of
5536 conditions used within @code{Postcondition} pragmas.
5537 The following example shows that it is even possible
5538 to verify performance behavior.
5539
5540 @smallexample @c ada
5541 package Sort is
5542
5543 Performance : constant Float;
5544 -- Performance constant set by implementation
5545 -- to match target architecture behavior.
5546
5547 procedure Treesort (Arg : String);
5548 -- Sorts characters of argument using N*logN sort
5549 pragma Postcondition
5550 (Float (Clock - Clock'Old) <=
5551 Float (Arg'Length) *
5552 log (Float (Arg'Length)) *
5553 Performance);
5554 end Sort;
5555 @end smallexample
5556
5557 @noindent
5558 Note: postcondition pragmas associated with subprograms that are
5559 marked as Inline_Always, or those marked as Inline with front-end
5560 inlining (-gnatN option set) are accepted and legality-checked
5561 by the compiler, but are ignored at run-time even if postcondition
5562 checking is enabled.
5563
5564 Note that pragma @code{Postcondition} differs from the language-defined
5565 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
5566 multiple occurrences, allowing occurences in the body even if there
5567 is a separate spec, and allowing a second string parameter, and the
5568 use of the pragma identifier @code{Check}. Historically, pragma
5569 @code{Postcondition} was implemented prior to the development of
5570 Ada 2012, and has been retained in its original form for
5571 compatibility purposes.
5572
5573 @node Pragma Post_Class
5574 @unnumberedsec Pragma Post_Class
5575 @cindex Post
5576 @cindex Checks, postconditions
5577 @findex Postconditions
5578 @noindent
5579 Syntax:
5580
5581 @smallexample @c ada
5582 pragma Post_Class (Boolean_Expression);
5583 @end smallexample
5584
5585 @noindent
5586 The @code{Post_Class} pragma is intended to be an exact replacement for
5587 the language-defined
5588 @code{Post'Class} aspect, and shares its restrictions and semantics.
5589 It must appear either immediately following the corresponding
5590 subprogram declaration (only other pragmas may intervene), or
5591 if there is no separate subprogram declaration, then it can
5592 appear at the start of the declarations in a subprogram body
5593 (preceded only by other pragmas).
5594
5595 Note: This pragma is called @code{Post_Class} rather than
5596 @code{Post'Class} because the latter would not be strictly
5597 conforming to the allowed syntax for pragmas. The motivation
5598 for provinding pragmas equivalent to the aspects is to allow a program
5599 to be written using the pragmas, and then compiled if necessary
5600 using an Ada compiler that does not recognize the pragmas or
5601 aspects, but is prepared to ignore the pragmas. The assertion
5602 policy that controls this pragma is @code{Post'Class}, not
5603 @code{Post_Class}.
5604
5605 @node Pragma Pre
5606 @unnumberedsec Pragma Pre
5607 @cindex Pre
5608 @cindex Checks, preconditions
5609 @findex Preconditions
5610 @noindent
5611 Syntax:
5612
5613 @smallexample @c ada
5614 pragma Pre (Boolean_Expression);
5615 @end smallexample
5616
5617 @noindent
5618 The @code{Pre} pragma is intended to be an exact replacement for
5619 the language-defined
5620 @code{Pre} aspect, and shares its restrictions and semantics.
5621 It must appear either immediately following the corresponding
5622 subprogram declaration (only other pragmas may intervene), or
5623 if there is no separate subprogram declaration, then it can
5624 appear at the start of the declarations in a subprogram body
5625 (preceded only by other pragmas).
5626
5627 @node Pragma Precondition
5628 @unnumberedsec Pragma Precondition
5629 @cindex Preconditions
5630 @cindex Checks, preconditions
5631 @findex Preconditions
5632 @noindent
5633 Syntax:
5634
5635 @smallexample @c ada
5636 pragma Precondition (
5637 [Check =>] Boolean_Expression
5638 [,[Message =>] String_Expression]);
5639 @end smallexample
5640
5641 @noindent
5642 The @code{Precondition} pragma is similar to @code{Postcondition}
5643 except that the corresponding checks take place immediately upon
5644 entry to the subprogram, and if a precondition fails, the exception
5645 is raised in the context of the caller, and the attribute 'Result
5646 cannot be used within the precondition expression.
5647
5648 Otherwise, the placement and visibility rules are identical to those
5649 described for postconditions. The following is an example of use
5650 within a package spec:
5651
5652 @smallexample @c ada
5653 package Math_Functions is
5654 ...
5655 function Sqrt (Arg : Float) return Float;
5656 pragma Precondition (Arg >= 0.0)
5657 ...
5658 end Math_Functions;
5659 @end smallexample
5660
5661 @noindent
5662 @code{Precondition} pragmas may appear either immediately following the
5663 (separate) declaration of a subprogram, or at the start of the
5664 declarations of a subprogram body. Only other pragmas may intervene
5665 (that is appear between the subprogram declaration and its
5666 postconditions, or appear before the postcondition in the
5667 declaration sequence in a subprogram body).
5668
5669 Note: precondition pragmas associated with subprograms that are
5670 marked as Inline_Always, or those marked as Inline with front-end
5671 inlining (-gnatN option set) are accepted and legality-checked
5672 by the compiler, but are ignored at run-time even if precondition
5673 checking is enabled.
5674
5675 Note that pragma @code{Precondition} differs from the language-defined
5676 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
5677 multiple occurrences, allowing occurences in the body even if there
5678 is a separate spec, and allowing a second string parameter, and the
5679 use of the pragma identifier @code{Check}. Historically, pragma
5680 @code{Precondition} was implemented prior to the development of
5681 Ada 2012, and has been retained in its original form for
5682 compatibility purposes.
5683
5684 @node Pragma Predicate
5685 @unnumberedsec Pragma Predicate
5686 @findex Predicate
5687 @findex Predicate pragma
5688 @noindent
5689 Syntax:
5690
5691 @smallexample @c ada
5692 pragma Predicate
5693 ([Entity =>] type_LOCAL_NAME,
5694 [Check =>] EXPRESSION);
5695 @end smallexample
5696
5697 @noindent
5698 This pragma (available in all versions of Ada in GNAT) encompasses both
5699 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
5700 Ada 2012. A predicate is regarded as static if it has an allowed form
5701 for @code{Static_Predicate} and is otherwise treated as a
5702 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
5703 pragma behave exactly as described in the Ada 2012 reference manual.
5704 For example, if we have
5705
5706 @smallexample @c ada
5707 type R is range 1 .. 10;
5708 subtype S is R;
5709 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
5710 subtype Q is R
5711 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
5712 @end smallexample
5713
5714 @noindent
5715 the effect is identical to the following Ada 2012 code:
5716
5717 @smallexample @c ada
5718 type R is range 1 .. 10;
5719 subtype S is R with
5720 Static_Predicate => S not in 4 .. 6;
5721 subtype Q is R with
5722 Dynamic_Predicate => F(Q) or G(Q);
5723 @end smallexample
5724
5725 Note that there is are no pragmas @code{Dynamic_Predicate}
5726 or @code{Static_Predicate}. That is
5727 because these pragmas would affect legality and semantics of
5728 the program and thus do not have a neutral effect if ignored.
5729 The motivation behind providing pragmas equivalent to
5730 corresponding aspects is to allow a program to be written
5731 using the pragmas, and then compiled with a compiler that
5732 will ignore the pragmas. That doesn't work in the case of
5733 static and dynamic predicates, since if the corresponding
5734 pragmas are ignored, then the behavior of the program is
5735 fundamentally changed (for example a membership test
5736 @code{A in B} would not take into account a predicate
5737 defined for subtype B). When following this approach, the
5738 use of predicates should be avoided.
5739
5740 @node Pragma Preelaborable_Initialization
5741 @unnumberedsec Pragma Preelaborable_Initialization
5742 @findex Preelaborable_Initialization
5743 @noindent
5744 Syntax:
5745
5746 @smallexample @c ada
5747 pragma Preelaborable_Initialization (DIRECT_NAME);
5748 @end smallexample
5749
5750 @noindent
5751 This pragma is standard in Ada 2005, but is available in all earlier
5752 versions of Ada as an implementation-defined pragma.
5753 See Ada 2012 Reference Manual for details.
5754
5755 @node Pragma Pre_Class
5756 @unnumberedsec Pragma Pre_Class
5757 @cindex Pre_Class
5758 @cindex Checks, preconditions
5759 @findex Preconditions
5760 @noindent
5761 Syntax:
5762
5763 @smallexample @c ada
5764 pragma Pre_Class (Boolean_Expression);
5765 @end smallexample
5766
5767 @noindent
5768 The @code{Pre_Class} pragma is intended to be an exact replacement for
5769 the language-defined
5770 @code{Pre'Class} aspect, and shares its restrictions and semantics.
5771 It must appear either immediately following the corresponding
5772 subprogram declaration (only other pragmas may intervene), or
5773 if there is no separate subprogram declaration, then it can
5774 appear at the start of the declarations in a subprogram body
5775 (preceded only by other pragmas).
5776
5777 Note: This pragma is called @code{Pre_Class} rather than
5778 @code{Pre'Class} because the latter would not be strictly
5779 conforming to the allowed syntax for pragmas. The motivation
5780 for providing pragmas equivalent to the aspects is to allow a program
5781 to be written using the pragmas, and then compiled if necessary
5782 using an Ada compiler that does not recognize the pragmas or
5783 aspects, but is prepared to ignore the pragmas. The assertion
5784 policy that controls this pragma is @code{Pre'Class}, not
5785 @code{Pre_Class}.
5786
5787 @node Pragma Priority_Specific_Dispatching
5788 @unnumberedsec Pragma Priority_Specific_Dispatching
5789 @findex Priority_Specific_Dispatching
5790 @noindent
5791 Syntax:
5792
5793 @smallexample @c ada
5794 pragma Priority_Specific_Dispatching (
5795 POLICY_IDENTIFIER,
5796 first_priority_EXPRESSION,
5797 last_priority_EXPRESSION)
5798
5799 POLICY_IDENTIFIER ::=
5800 EDF_Across_Priorities |
5801 FIFO_Within_Priorities |
5802 Non_Preemptive_Within_Priorities |
5803 Round_Robin_Within_Priorities
5804 @end smallexample
5805
5806 @noindent
5807 This pragma is standard in Ada 2005, but is available in all earlier
5808 versions of Ada as an implementation-defined pragma.
5809 See Ada 2012 Reference Manual for details.
5810
5811 @node Pragma Profile
5812 @unnumberedsec Pragma Profile
5813 @findex Profile
5814 @noindent
5815 Syntax:
5816
5817 @smallexample @c ada
5818 pragma Profile (Ravenscar | Restricted | Rational);
5819 @end smallexample
5820
5821 @noindent
5822 This pragma is standard in Ada 2005, but is available in all earlier
5823 versions of Ada as an implementation-defined pragma. This is a
5824 configuration pragma that establishes a set of configiuration pragmas
5825 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
5826 The other two possibilities (@code{Restricted} or @code{Rational})
5827 are implementation-defined. The set of configuration pragmas
5828 is defined in the following sections.
5829
5830 @itemize
5831
5832 @item Pragma Profile (Ravenscar)
5833 @findex Ravenscar
5834 @noindent
5835
5836 The @code{Ravenscar} profile is standard in Ada 2005,
5837 but is available in all earlier
5838 versions of Ada as an implementation-defined pragma. This profile
5839 establishes the following set of configuration pragmas:
5840
5841 @table @code
5842 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
5843 [RM D.2.2] Tasks are dispatched following a preemptive
5844 priority-ordered scheduling policy.
5845
5846 @item Locking_Policy (Ceiling_Locking)
5847 [RM D.3] While tasks and interrupts execute a protected action, they inherit
5848 the ceiling priority of the corresponding protected object.
5849
5850 @item Detect_Blocking
5851 This pragma forces the detection of potentially blocking operations within a
5852 protected operation, and to raise Program_Error if that happens.
5853 @end table
5854 @noindent
5855
5856 plus the following set of restrictions:
5857
5858 @table @code
5859 @item Max_Entry_Queue_Length => 1
5860 No task can be queued on a protected entry.
5861 @item Max_Protected_Entries => 1
5862 @item Max_Task_Entries => 0
5863 No rendezvous statements are allowed.
5864 @item No_Abort_Statements
5865 @item No_Dynamic_Attachment
5866 @item No_Dynamic_Priorities
5867 @item No_Implicit_Heap_Allocations
5868 @item No_Local_Protected_Objects
5869 @item No_Local_Timing_Events
5870 @item No_Protected_Type_Allocators
5871 @item No_Relative_Delay
5872 @item No_Requeue_Statements
5873 @item No_Select_Statements
5874 @item No_Specific_Termination_Handlers
5875 @item No_Task_Allocators
5876 @item No_Task_Hierarchy
5877 @item No_Task_Termination
5878 @item Simple_Barriers
5879 @end table
5880 @noindent
5881
5882 The Ravenscar profile also includes the following restrictions that specify
5883 that there are no semantic dependences on the corresponding predefined
5884 packages:
5885
5886 @table @code
5887 @item No_Dependence => Ada.Asynchronous_Task_Control
5888 @item No_Dependence => Ada.Calendar
5889 @item No_Dependence => Ada.Execution_Time.Group_Budget
5890 @item No_Dependence => Ada.Execution_Time.Timers
5891 @item No_Dependence => Ada.Task_Attributes
5892 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
5893 @end table
5894
5895 @noindent
5896
5897 This set of configuration pragmas and restrictions correspond to the
5898 definition of the ``Ravenscar Profile'' for limited tasking, devised and
5899 published by the @cite{International Real-Time Ada Workshop}, 1997,
5900 and whose most recent description is available at
5901 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
5902
5903 The original definition of the profile was revised at subsequent IRTAW
5904 meetings. It has been included in the ISO
5905 @cite{Guide for the Use of the Ada Programming Language in High
5906 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
5907 the next revision of the standard. The formal definition given by
5908 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
5909 AI-305) available at
5910 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
5911 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
5912
5913 The above set is a superset of the restrictions provided by pragma
5914 @code{Profile (Restricted)}, it includes six additional restrictions
5915 (@code{Simple_Barriers}, @code{No_Select_Statements},
5916 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
5917 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
5918 that pragma @code{Profile (Ravenscar)}, like the pragma
5919 @code{Profile (Restricted)},
5920 automatically causes the use of a simplified,
5921 more efficient version of the tasking run-time system.
5922
5923 @item Pragma Profile (Restricted)
5924 @findex Restricted Run Time
5925 @noindent
5926 This profile corresponds to the GNAT restricted run time. It
5927 establishes the following set of restrictions:
5928
5929 @itemize @bullet
5930 @item No_Abort_Statements
5931 @item No_Entry_Queue
5932 @item No_Task_Hierarchy
5933 @item No_Task_Allocators
5934 @item No_Dynamic_Priorities
5935 @item No_Terminate_Alternatives
5936 @item No_Dynamic_Attachment
5937 @item No_Protected_Type_Allocators
5938 @item No_Local_Protected_Objects
5939 @item No_Requeue_Statements
5940 @item No_Task_Attributes_Package
5941 @item Max_Asynchronous_Select_Nesting = 0
5942 @item Max_Task_Entries = 0
5943 @item Max_Protected_Entries = 1
5944 @item Max_Select_Alternatives = 0
5945 @end itemize
5946
5947 @noindent
5948 This set of restrictions causes the automatic selection of a simplified
5949 version of the run time that provides improved performance for the
5950 limited set of tasking functionality permitted by this set of restrictions.
5951
5952 @item Pragma Profile (Rational)
5953 @findex Rational compatibility mode
5954 @noindent
5955 The Rational profile is intended to facilitate porting legacy code that
5956 compiles with the Rational APEX compiler, even when the code includes non-
5957 conforming Ada constructs. The profile enables the following three pragmas:
5958
5959 @itemize @bullet
5960 @item pragma Implicit_Packing
5961 @item pragma Overriding_Renamings
5962 @item pragma Use_VADS_Size
5963 @end itemize
5964
5965 @end itemize
5966
5967 @node Pragma Profile_Warnings
5968 @unnumberedsec Pragma Profile_Warnings
5969 @findex Profile_Warnings
5970 @noindent
5971 Syntax:
5972
5973 @smallexample @c ada
5974 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
5975 @end smallexample
5976
5977 @noindent
5978 This is an implementation-defined pragma that is similar in
5979 effect to @code{pragma Profile} except that instead of
5980 generating @code{Restrictions} pragmas, it generates
5981 @code{Restriction_Warnings} pragmas. The result is that
5982 violations of the profile generate warning messages instead
5983 of error messages.
5984
5985 @node Pragma Propagate_Exceptions
5986 @unnumberedsec Pragma Propagate_Exceptions
5987 @cindex Interfacing to C++
5988 @findex Propagate_Exceptions
5989 @noindent
5990 Syntax:
5991
5992 @smallexample @c ada
5993 pragma Propagate_Exceptions;
5994 @end smallexample
5995
5996 @noindent
5997 This pragma is now obsolete and, other than generating a warning if warnings
5998 on obsolescent features are enabled, is ignored.
5999 It is retained for compatibility
6000 purposes. It used to be used in connection with optimization of
6001 a now-obsolete mechanism for implementation of exceptions.
6002
6003 @node Pragma Provide_Shift_Operators
6004 @unnumberedsec Pragma Provide_Shift_Operators
6005 @cindex Shift operators
6006 @findex Provide_Shift_Operators
6007 @noindent
6008 Syntax:
6009
6010 @smallexample @c ada
6011 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
6012 @end smallexample
6013
6014 @noindent
6015 This pragma can be applied to a first subtype local name that specifies
6016 either an unsigned or signed type. It has the effect of providing the
6017 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
6018 Rotate_Left and Rotate_Right) for the given type. It is similar to
6019 including the function declarations for these five operators, together
6020 with the pragma Import (Intrinsic, ...) statements.
6021
6022 @node Pragma Psect_Object
6023 @unnumberedsec Pragma Psect_Object
6024 @findex Psect_Object
6025 @noindent
6026 Syntax:
6027
6028 @smallexample @c ada
6029 pragma Psect_Object (
6030 [Internal =>] LOCAL_NAME,
6031 [, [External =>] EXTERNAL_SYMBOL]
6032 [, [Size =>] EXTERNAL_SYMBOL]);
6033
6034 EXTERNAL_SYMBOL ::=
6035 IDENTIFIER
6036 | static_string_EXPRESSION
6037 @end smallexample
6038
6039 @noindent
6040 This pragma is identical in effect to pragma @code{Common_Object}.
6041
6042 @node Pragma Pure_Function
6043 @unnumberedsec Pragma Pure_Function
6044 @findex Pure_Function
6045 @noindent
6046 Syntax:
6047
6048 @smallexample @c ada
6049 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
6050 @end smallexample
6051
6052 @noindent
6053 This pragma appears in the same declarative part as a function
6054 declaration (or a set of function declarations if more than one
6055 overloaded declaration exists, in which case the pragma applies
6056 to all entities). It specifies that the function @code{Entity} is
6057 to be considered pure for the purposes of code generation. This means
6058 that the compiler can assume that there are no side effects, and
6059 in particular that two calls with identical arguments produce the
6060 same result. It also means that the function can be used in an
6061 address clause.
6062
6063 Note that, quite deliberately, there are no static checks to try
6064 to ensure that this promise is met, so @code{Pure_Function} can be used
6065 with functions that are conceptually pure, even if they do modify
6066 global variables. For example, a square root function that is
6067 instrumented to count the number of times it is called is still
6068 conceptually pure, and can still be optimized, even though it
6069 modifies a global variable (the count). Memo functions are another
6070 example (where a table of previous calls is kept and consulted to
6071 avoid re-computation).
6072
6073 Note also that the normal rules excluding optimization of subprograms
6074 in pure units (when parameter types are descended from System.Address,
6075 or when the full view of a parameter type is limited), do not apply
6076 for the Pure_Function case. If you explicitly specify Pure_Function,
6077 the compiler may optimize away calls with identical arguments, and
6078 if that results in unexpected behavior, the proper action is not to
6079 use the pragma for subprograms that are not (conceptually) pure.
6080
6081 @findex Pure
6082 Note: Most functions in a @code{Pure} package are automatically pure, and
6083 there is no need to use pragma @code{Pure_Function} for such functions. One
6084 exception is any function that has at least one formal of type
6085 @code{System.Address} or a type derived from it. Such functions are not
6086 considered pure by default, since the compiler assumes that the
6087 @code{Address} parameter may be functioning as a pointer and that the
6088 referenced data may change even if the address value does not.
6089 Similarly, imported functions are not considered to be pure by default,
6090 since there is no way of checking that they are in fact pure. The use
6091 of pragma @code{Pure_Function} for such a function will override these default
6092 assumption, and cause the compiler to treat a designated subprogram as pure
6093 in these cases.
6094
6095 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
6096 applies to the underlying renamed function. This can be used to
6097 disambiguate cases of overloading where some but not all functions
6098 in a set of overloaded functions are to be designated as pure.
6099
6100 If pragma @code{Pure_Function} is applied to a library level function, the
6101 function is also considered pure from an optimization point of view, but the
6102 unit is not a Pure unit in the categorization sense. So for example, a function
6103 thus marked is free to @code{with} non-pure units.
6104
6105 @node Pragma Rational
6106 @unnumberedsec Pragma Rational
6107 @findex Rational
6108 @noindent
6109 Syntax:
6110
6111 @smallexample @c ada
6112 pragma Rational;
6113 @end smallexample
6114
6115 @noindent
6116 This pragma is considered obsolescent, but is retained for
6117 compatibility purposes. It is equivalent to:
6118
6119 @smallexample @c ada
6120 pragma Profile (Rational);
6121 @end smallexample
6122
6123 @node Pragma Ravenscar
6124 @unnumberedsec Pragma Ravenscar
6125 @findex Pragma Ravenscar
6126 @noindent
6127 Syntax:
6128
6129 @smallexample @c ada
6130 pragma Ravenscar;
6131 @end smallexample
6132
6133 @noindent
6134 This pragma is considered obsolescent, but is retained for
6135 compatibility purposes. It is equivalent to:
6136
6137 @smallexample @c ada
6138 pragma Profile (Ravenscar);
6139 @end smallexample
6140
6141 @noindent
6142 which is the preferred method of setting the @code{Ravenscar} profile.
6143
6144 @node Pragma Refined_Depends
6145 @unnumberedsec Pragma Refined_Depends
6146 @findex Refined_Depends
6147 @noindent
6148 For the description of this pragma, see SPARK 2014 Reference Manual,
6149 section 6.1.5.
6150
6151 @node Pragma Refined_Global
6152 @unnumberedsec Pragma Refined_Global
6153 @findex Refined_Global
6154 @noindent
6155 For the description of this pragma, see SPARK 2014 Reference Manual,
6156 section 6.1.4.
6157
6158 @node Pragma Refined_Post
6159 @unnumberedsec Pragma Refined_Post
6160 @findex Refined_Post
6161 @noindent
6162 For the description of this pragma, see SPARK 2014 Reference Manual,
6163 section 7.2.7.
6164
6165 @node Pragma Refined_State
6166 @unnumberedsec Pragma Refined_State
6167 @findex Refined_State
6168 @noindent
6169 For the description of this pragma, see SPARK 2014 Reference Manual,
6170 section 7.2.2.
6171
6172 @node Pragma Relative_Deadline
6173 @unnumberedsec Pragma Relative_Deadline
6174 @findex Relative_Deadline
6175 @noindent
6176 Syntax:
6177
6178 @smallexample @c ada
6179 pragma Relative_Deadline (time_span_EXPRESSION);
6180 @end smallexample
6181
6182 @noindent
6183 This pragma is standard in Ada 2005, but is available in all earlier
6184 versions of Ada as an implementation-defined pragma.
6185 See Ada 2012 Reference Manual for details.
6186
6187 @node Pragma Remote_Access_Type
6188 @unnumberedsec Pragma Remote_Access_Type
6189 @findex Remote_Access_Type
6190 @noindent
6191 Syntax:
6192
6193 @smallexample @c ada
6194 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
6195 @end smallexample
6196
6197 @noindent
6198 This pragma appears in the formal part of a generic declaration.
6199 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
6200 the use of a remote access to class-wide type as actual for a formal
6201 access type.
6202
6203 When this pragma applies to a formal access type @code{Entity}, that
6204 type is treated as a remote access to class-wide type in the generic.
6205 It must be a formal general access type, and its designated type must
6206 be the class-wide type of a formal tagged limited private type from the
6207 same generic declaration.
6208
6209 In the generic unit, the formal type is subject to all restrictions
6210 pertaining to remote access to class-wide types. At instantiation, the
6211 actual type must be a remote access to class-wide type.
6212
6213 @node Pragma Restricted_Run_Time
6214 @unnumberedsec Pragma Restricted_Run_Time
6215 @findex Pragma Restricted_Run_Time
6216 @noindent
6217 Syntax:
6218
6219 @smallexample @c ada
6220 pragma Restricted_Run_Time;
6221 @end smallexample
6222
6223 @noindent
6224 This pragma is considered obsolescent, but is retained for
6225 compatibility purposes. It is equivalent to:
6226
6227 @smallexample @c ada
6228 pragma Profile (Restricted);
6229 @end smallexample
6230
6231 @noindent
6232 which is the preferred method of setting the restricted run time
6233 profile.
6234
6235 @node Pragma Restriction_Warnings
6236 @unnumberedsec Pragma Restriction_Warnings
6237 @findex Restriction_Warnings
6238 @noindent
6239 Syntax:
6240
6241 @smallexample @c ada
6242 pragma Restriction_Warnings
6243 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
6244 @end smallexample
6245
6246 @noindent
6247 This pragma allows a series of restriction identifiers to be
6248 specified (the list of allowed identifiers is the same as for
6249 pragma @code{Restrictions}). For each of these identifiers
6250 the compiler checks for violations of the restriction, but
6251 generates a warning message rather than an error message
6252 if the restriction is violated.
6253
6254 One use of this is in situations where you want to know
6255 about violations of a restriction, but you want to ignore some of
6256 these violations. Consider this example, where you want to set
6257 Ada_95 mode and enable style checks, but you want to know about
6258 any other use of implementation pragmas:
6259
6260 @smallexample @c ada
6261 pragma Restriction_Warnings (No_Implementation_Pragmas);
6262 pragma Warnings (Off, "violation of*No_Implementation_Pragmas*");
6263 pragma Ada_95;
6264 pragma Style_Checks ("2bfhkM160");
6265 pragma Warnings (On, "violation of*No_Implementation_Pragmas*");
6266 @end smallexample
6267
6268 @noindent
6269 By including the above lines in a configuration pragmas file,
6270 the Ada_95 and Style_Checks pragmas are accepted without
6271 generating a warning, but any other use of implementation
6272 defined pragmas will cause a warning to be generated.
6273
6274 @node Pragma Reviewable
6275 @unnumberedsec Pragma Reviewable
6276 @findex Reviewable
6277 @noindent
6278 Syntax:
6279
6280 @smallexample @c ada
6281 pragma Reviewable;
6282 @end smallexample
6283
6284 @noindent
6285 This pragma is an RM-defined standard pragma, but has no effect on the
6286 program being compiled, or on the code generated for the program.
6287
6288 To obtain the required output specified in RM H.3.1, the compiler must be
6289 run with various special switches as follows:
6290
6291 @table @i
6292
6293 @item Where compiler-generated run-time checks remain
6294
6295 The switch @option{-gnatGL}
6296 @findex @option{-gnatGL}
6297 may be used to list the expanded code in pseudo-Ada form.
6298 Runtime checks show up in the listing either as explicit
6299 checks or operators marked with @{@} to indicate a check is present.
6300
6301 @item An identification of known exceptions at compile time
6302
6303 If the program is compiled with @option{-gnatwa},
6304 @findex @option{-gnatwa}
6305 the compiler warning messages will indicate all cases where the compiler
6306 detects that an exception is certain to occur at run time.
6307
6308 @item Possible reads of uninitialized variables
6309
6310 The compiler warns of many such cases, but its output is incomplete.
6311 @ifclear FSFEDITION
6312 The CodePeer analysis tool
6313 @findex CodePeer static analysis tool
6314 @end ifclear
6315 @ifset FSFEDITION
6316 A supplemental static analysis tool
6317 @end ifset
6318 may be used to obtain a comprehensive list of all
6319 possible points at which uninitialized data may be read.
6320
6321 @item Where run-time support routines are implicitly invoked
6322
6323 In the output from @option{-gnatGL},
6324 @findex @option{-gnatGL}
6325 run-time calls are explicitly listed as calls to the relevant
6326 run-time routine.
6327
6328 @item Object code listing
6329
6330 This may be obtained either by using the @option{-S} switch,
6331 @findex @option{-S}
6332 or the objdump utility.
6333 @findex objdump
6334
6335 @item Constructs known to be erroneous at compile time
6336
6337 These are identified by warnings issued by the compiler (use @option{-gnatwa}).
6338 @findex @option{-gnatwa}
6339
6340 @item Stack usage information
6341
6342 Static stack usage data (maximum per-subprogram) can be obtained via the
6343 @option{-fstack-usage} switch to the compiler.
6344 @findex @option{-fstack-usage}
6345 Dynamic stack usage data (per task) can be obtained via the @option{-u} switch
6346 to gnatbind
6347 @findex @option{-u}
6348 @ifclear FSFEDITION
6349 The gnatstack utility
6350 @findex gnatstack
6351 can be used to provide additional information on stack usage.
6352 @end ifclear
6353
6354 @item Object code listing of entire partition
6355
6356 This can be obtained by compiling the partition with @option{-S},
6357 @findex @option{-S}
6358 or by applying objdump
6359 @findex objdump
6360 to all the object files that are part of the partition.
6361
6362 @item A description of the run-time model
6363
6364 The full sources of the run-time are available, and the documentation of
6365 these routines describes how these run-time routines interface to the
6366 underlying operating system facilities.
6367
6368 @item Control and data-flow information
6369
6370 @ifclear FSFEDITION
6371 The CodePeer tool
6372 @findex CodePeer static analysis tool
6373 @end ifclear
6374 @ifset FSFEDITION
6375 A supplemental static analysis tool
6376 @end ifset
6377 may be used to obtain complete control and data-flow information, as well as
6378 comprehensive messages identifying possible problems based on this
6379 information.
6380 @end table
6381
6382 @node Pragma Share_Generic
6383 @unnumberedsec Pragma Share_Generic
6384 @findex Share_Generic
6385 @noindent
6386 Syntax:
6387
6388 @smallexample @c ada
6389 pragma Share_Generic (GNAME @{, GNAME@});
6390
6391 GNAME ::= generic_unit_NAME | generic_instance_NAME
6392 @end smallexample
6393
6394 @noindent
6395 This pragma is provided for compatibility with Dec Ada 83. It has
6396 no effect in @code{GNAT} (which does not implement shared generics), other
6397 than to check that the given names are all names of generic units or
6398 generic instances.
6399
6400 @node Pragma Shared
6401 @unnumberedsec Pragma Shared
6402 @findex Shared
6403
6404 @noindent
6405 This pragma is provided for compatibility with Ada 83. The syntax and
6406 semantics are identical to pragma Atomic.
6407
6408 @node Pragma Short_Circuit_And_Or
6409 @unnumberedsec Pragma Short_Circuit_And_Or
6410 @findex Short_Circuit_And_Or
6411 @noindent
6412 Syntax:
6413
6414 @smallexample @c ada
6415 pragma Short_Circuit_And_Or;
6416 @end smallexample
6417
6418 @noindent
6419 This configuration pragma causes any occurrence of the AND operator applied to
6420 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
6421 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
6422 may be useful in the context of certification protocols requiring the use of
6423 short-circuited logical operators. If this configuration pragma occurs locally
6424 within the file being compiled, it applies only to the file being compiled.
6425 There is no requirement that all units in a partition use this option.
6426
6427 @node Pragma Short_Descriptors
6428 @unnumberedsec Pragma Short_Descriptors
6429 @findex Short_Descriptors
6430 @noindent
6431 Syntax:
6432
6433 @smallexample @c ada
6434 pragma Short_Descriptors
6435 @end smallexample
6436
6437 @noindent
6438 In VMS versions of the compiler, this configuration pragma causes all
6439 occurrences of the mechanism types Descriptor[_xxx] to be treated as
6440 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
6441 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
6442 versions.
6443
6444 @node Pragma Simple_Storage_Pool_Type
6445 @unnumberedsec Pragma Simple_Storage_Pool_Type
6446 @findex Simple_Storage_Pool_Type
6447 @cindex Storage pool, simple
6448 @cindex Simple storage pool
6449 @noindent
6450 Syntax:
6451
6452 @smallexample @c ada
6453 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
6454 @end smallexample
6455
6456 @noindent
6457 A type can be established as a ``simple storage pool type'' by applying
6458 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
6459 A type named in the pragma must be a library-level immutably limited record
6460 type or limited tagged type declared immediately within a package declaration.
6461 The type can also be a limited private type whose full type is allowed as
6462 a simple storage pool type.
6463
6464 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
6465 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
6466 are subtype conformant with the following subprogram declarations:
6467
6468 @smallexample @c ada
6469 procedure Allocate
6470 (Pool : in out SSP;
6471 Storage_Address : out System.Address;
6472 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6473 Alignment : System.Storage_Elements.Storage_Count);
6474
6475 procedure Deallocate
6476 (Pool : in out SSP;
6477 Storage_Address : System.Address;
6478 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
6479 Alignment : System.Storage_Elements.Storage_Count);
6480
6481 function Storage_Size (Pool : SSP)
6482 return System.Storage_Elements.Storage_Count;
6483 @end smallexample
6484
6485 @noindent
6486 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
6487 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
6488 applying an unchecked deallocation has no effect other than to set its actual
6489 parameter to null. If @code{Storage_Size} is not declared, then the
6490 @code{Storage_Size} attribute applied to an access type associated with
6491 a pool object of type SSP returns zero. Additional operations can be declared
6492 for a simple storage pool type (such as for supporting a mark/release
6493 storage-management discipline).
6494
6495 An object of a simple storage pool type can be associated with an access
6496 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
6497
6498 @smallexample @c ada
6499
6500 My_Pool : My_Simple_Storage_Pool_Type;
6501
6502 type Acc is access My_Data_Type;
6503
6504 for Acc'Simple_Storage_Pool use My_Pool;
6505
6506 @end smallexample
6507
6508 @noindent
6509 See attribute @code{Simple_Storage_Pool} for further details.
6510
6511 @node Pragma Source_File_Name
6512 @unnumberedsec Pragma Source_File_Name
6513 @findex Source_File_Name
6514 @noindent
6515 Syntax:
6516
6517 @smallexample @c ada
6518 pragma Source_File_Name (
6519 [Unit_Name =>] unit_NAME,
6520 Spec_File_Name => STRING_LITERAL,
6521 [Index => INTEGER_LITERAL]);
6522
6523 pragma Source_File_Name (
6524 [Unit_Name =>] unit_NAME,
6525 Body_File_Name => STRING_LITERAL,
6526 [Index => INTEGER_LITERAL]);
6527 @end smallexample
6528
6529 @noindent
6530 Use this to override the normal naming convention. It is a configuration
6531 pragma, and so has the usual applicability of configuration pragmas
6532 (i.e.@: it applies to either an entire partition, or to all units in a
6533 compilation, or to a single unit, depending on how it is used.
6534 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
6535 the second argument is required, and indicates whether this is the file
6536 name for the spec or for the body.
6537
6538 The optional Index argument should be used when a file contains multiple
6539 units, and when you do not want to use @code{gnatchop} to separate then
6540 into multiple files (which is the recommended procedure to limit the
6541 number of recompilations that are needed when some sources change).
6542 For instance, if the source file @file{source.ada} contains
6543
6544 @smallexample @c ada
6545 package B is
6546 ...
6547 end B;
6548
6549 with B;
6550 procedure A is
6551 begin
6552 ..
6553 end A;
6554 @end smallexample
6555
6556 you could use the following configuration pragmas:
6557
6558 @smallexample @c ada
6559 pragma Source_File_Name
6560 (B, Spec_File_Name => "source.ada", Index => 1);
6561 pragma Source_File_Name
6562 (A, Body_File_Name => "source.ada", Index => 2);
6563 @end smallexample
6564
6565 Note that the @code{gnatname} utility can also be used to generate those
6566 configuration pragmas.
6567
6568 Another form of the @code{Source_File_Name} pragma allows
6569 the specification of patterns defining alternative file naming schemes
6570 to apply to all files.
6571
6572 @smallexample @c ada
6573 pragma Source_File_Name
6574 ( [Spec_File_Name =>] STRING_LITERAL
6575 [,[Casing =>] CASING_SPEC]
6576 [,[Dot_Replacement =>] STRING_LITERAL]);
6577
6578 pragma Source_File_Name
6579 ( [Body_File_Name =>] STRING_LITERAL
6580 [,[Casing =>] CASING_SPEC]
6581 [,[Dot_Replacement =>] STRING_LITERAL]);
6582
6583 pragma Source_File_Name
6584 ( [Subunit_File_Name =>] STRING_LITERAL
6585 [,[Casing =>] CASING_SPEC]
6586 [,[Dot_Replacement =>] STRING_LITERAL]);
6587
6588 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
6589 @end smallexample
6590
6591 @noindent
6592 The first argument is a pattern that contains a single asterisk indicating
6593 the point at which the unit name is to be inserted in the pattern string
6594 to form the file name. The second argument is optional. If present it
6595 specifies the casing of the unit name in the resulting file name string.
6596 The default is lower case. Finally the third argument allows for systematic
6597 replacement of any dots in the unit name by the specified string literal.
6598
6599 Note that Source_File_Name pragmas should not be used if you are using
6600 project files. The reason for this rule is that the project manager is not
6601 aware of these pragmas, and so other tools that use the projet file would not
6602 be aware of the intended naming conventions. If you are using project files,
6603 file naming is controlled by Source_File_Name_Project pragmas, which are
6604 usually supplied automatically by the project manager. A pragma
6605 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
6606
6607 For more details on the use of the @code{Source_File_Name} pragma,
6608 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
6609 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
6610 User's Guide}.
6611
6612 @node Pragma Source_File_Name_Project
6613 @unnumberedsec Pragma Source_File_Name_Project
6614 @findex Source_File_Name_Project
6615 @noindent
6616
6617 This pragma has the same syntax and semantics as pragma Source_File_Name.
6618 It is only allowed as a stand alone configuration pragma.
6619 It cannot appear after a @ref{Pragma Source_File_Name}, and
6620 most importantly, once pragma Source_File_Name_Project appears,
6621 no further Source_File_Name pragmas are allowed.
6622
6623 The intention is that Source_File_Name_Project pragmas are always
6624 generated by the Project Manager in a manner consistent with the naming
6625 specified in a project file, and when naming is controlled in this manner,
6626 it is not permissible to attempt to modify this naming scheme using
6627 Source_File_Name or Source_File_Name_Project pragmas (which would not be
6628 known to the project manager).
6629
6630 @node Pragma Source_Reference
6631 @unnumberedsec Pragma Source_Reference
6632 @findex Source_Reference
6633 @noindent
6634 Syntax:
6635
6636 @smallexample @c ada
6637 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
6638 @end smallexample
6639
6640 @noindent
6641 This pragma must appear as the first line of a source file.
6642 @var{integer_literal} is the logical line number of the line following
6643 the pragma line (for use in error messages and debugging
6644 information). @var{string_literal} is a static string constant that
6645 specifies the file name to be used in error messages and debugging
6646 information. This is most notably used for the output of @code{gnatchop}
6647 with the @option{-r} switch, to make sure that the original unchopped
6648 source file is the one referred to.
6649
6650 The second argument must be a string literal, it cannot be a static
6651 string expression other than a string literal. This is because its value
6652 is needed for error messages issued by all phases of the compiler.
6653
6654 @node Pragma SPARK_Mode
6655 @unnumberedsec Pragma SPARK_Mode
6656 @findex SPARK_Mode
6657 @noindent
6658 Syntax:
6659
6660 @smallexample @c ada
6661 pragma SPARK_Mode [(On | Off)] ;
6662 @end smallexample
6663
6664 @noindent
6665 In general a program can have some parts that are in SPARK 2014 (and
6666 follow all the rules in the SPARK Reference Manual), and some parts
6667 that are full Ada 2012.
6668
6669 The SPARK_Mode pragma is used to identify which parts are in SPARK
6670 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
6671 be used in the following places:
6672
6673 @itemize @bullet
6674
6675 @item
6676 As a configuration pragma, in which case it sets the default mode for
6677 all units compiled with this pragma.
6678
6679 @item
6680 Immediately following a library-level subprogram spec
6681
6682 @item
6683 Immediately within a library-level package body
6684
6685 @item
6686 Immediately following the @code{private} keyword of a library-level
6687 package spec
6688
6689 @item
6690 Immediately following the @code{begin} keyword of a library-level
6691 package body
6692
6693 @item
6694 Immediately within a library-level subprogram body
6695
6696 @end itemize
6697
6698 @noindent
6699 Normally a subprogram or package spec/body inherits the current mode
6700 that is active at the point it is declared. But this can be overridden
6701 by pragma within the spec or body as above.
6702
6703 The basic consistency rule is that you can't turn SPARK_Mode back
6704 @code{On}, once you have explicitly (with a pragma) turned if
6705 @code{Off}. So the following rules apply:
6706
6707 @noindent
6708 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
6709 also have SPARK_Mode @code{Off}.
6710
6711 @noindent
6712 For a package, we have four parts:
6713
6714 @itemize
6715 @item
6716 the package public declarations
6717 @item
6718 the package private part
6719 @item
6720 the body of the package
6721 @item
6722 the elaboration code after @code{begin}
6723 @end itemize
6724
6725 @noindent
6726 For a package, the rule is that if you explicitly turn SPARK_Mode
6727 @code{Off} for any part, then all the following parts must have
6728 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
6729 SPARK_Mode (@code{Off}) in the body. For example, if we have a
6730 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
6731 default everywhere, and one particular package spec has pragma
6732 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
6733 the package body.
6734
6735 @node Pragma Static_Elaboration_Desired
6736 @unnumberedsec Pragma Static_Elaboration_Desired
6737 @findex Static_Elaboration_Desired
6738 @noindent
6739 Syntax:
6740
6741 @smallexample @c ada
6742 pragma Static_Elaboration_Desired;
6743 @end smallexample
6744
6745 @noindent
6746 This pragma is used to indicate that the compiler should attempt to initialize
6747 statically the objects declared in the library unit to which the pragma applies,
6748 when these objects are initialized (explicitly or implicitly) by an aggregate.
6749 In the absence of this pragma, aggregates in object declarations are expanded
6750 into assignments and loops, even when the aggregate components are static
6751 constants. When the aggregate is present the compiler builds a static expression
6752 that requires no run-time code, so that the initialized object can be placed in
6753 read-only data space. If the components are not static, or the aggregate has
6754 more that 100 components, the compiler emits a warning that the pragma cannot
6755 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
6756 construction of larger aggregates with static components that include an others
6757 choice.)
6758
6759 @node Pragma Stream_Convert
6760 @unnumberedsec Pragma Stream_Convert
6761 @findex Stream_Convert
6762 @noindent
6763 Syntax:
6764
6765 @smallexample @c ada
6766 pragma Stream_Convert (
6767 [Entity =>] type_LOCAL_NAME,
6768 [Read =>] function_NAME,
6769 [Write =>] function_NAME);
6770 @end smallexample
6771
6772 @noindent
6773 This pragma provides an efficient way of providing user-defined stream
6774 attributes. Not only is it simpler to use than specifying the attributes
6775 directly, but more importantly, it allows the specification to be made in such
6776 a way that the predefined unit Ada.Streams is not loaded unless it is actually
6777 needed (i.e. unless the stream attributes are actually used); the use of
6778 the Stream_Convert pragma adds no overhead at all, unless the stream
6779 attributes are actually used on the designated type.
6780
6781 The first argument specifies the type for which stream functions are
6782 provided. The second parameter provides a function used to read values
6783 of this type. It must name a function whose argument type may be any
6784 subtype, and whose returned type must be the type given as the first
6785 argument to the pragma.
6786
6787 The meaning of the @var{Read} parameter is that if a stream attribute directly
6788 or indirectly specifies reading of the type given as the first parameter,
6789 then a value of the type given as the argument to the Read function is
6790 read from the stream, and then the Read function is used to convert this
6791 to the required target type.
6792
6793 Similarly the @var{Write} parameter specifies how to treat write attributes
6794 that directly or indirectly apply to the type given as the first parameter.
6795 It must have an input parameter of the type specified by the first parameter,
6796 and the return type must be the same as the input type of the Read function.
6797 The effect is to first call the Write function to convert to the given stream
6798 type, and then write the result type to the stream.
6799
6800 The Read and Write functions must not be overloaded subprograms. If necessary
6801 renamings can be supplied to meet this requirement.
6802 The usage of this attribute is best illustrated by a simple example, taken
6803 from the GNAT implementation of package Ada.Strings.Unbounded:
6804
6805 @smallexample @c ada
6806 function To_Unbounded (S : String)
6807 return Unbounded_String
6808 renames To_Unbounded_String;
6809
6810 pragma Stream_Convert
6811 (Unbounded_String, To_Unbounded, To_String);
6812 @end smallexample
6813
6814 @noindent
6815 The specifications of the referenced functions, as given in the Ada
6816 Reference Manual are:
6817
6818 @smallexample @c ada
6819 function To_Unbounded_String (Source : String)
6820 return Unbounded_String;
6821
6822 function To_String (Source : Unbounded_String)
6823 return String;
6824 @end smallexample
6825
6826 @noindent
6827 The effect is that if the value of an unbounded string is written to a stream,
6828 then the representation of the item in the stream is in the same format that
6829 would be used for @code{Standard.String'Output}, and this same representation
6830 is expected when a value of this type is read from the stream. Note that the
6831 value written always includes the bounds, even for Unbounded_String'Write,
6832 since Unbounded_String is not an array type.
6833
6834 Note that the @code{Stream_Convert} pragma is not effective in the case of
6835 a derived type of a non-limited tagged type. If such a type is specified then
6836 the pragma is silently ignored, and the default implementation of the stream
6837 attributes is used instead.
6838
6839 @node Pragma Style_Checks
6840 @unnumberedsec Pragma Style_Checks
6841 @findex Style_Checks
6842 @noindent
6843 Syntax:
6844
6845 @smallexample @c ada
6846 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
6847 On | Off [, LOCAL_NAME]);
6848 @end smallexample
6849
6850 @noindent
6851 This pragma is used in conjunction with compiler switches to control the
6852 built in style checking provided by GNAT@. The compiler switches, if set,
6853 provide an initial setting for the switches, and this pragma may be used
6854 to modify these settings, or the settings may be provided entirely by
6855 the use of the pragma. This pragma can be used anywhere that a pragma
6856 is legal, including use as a configuration pragma (including use in
6857 the @file{gnat.adc} file).
6858
6859 The form with a string literal specifies which style options are to be
6860 activated. These are additive, so they apply in addition to any previously
6861 set style check options. The codes for the options are the same as those
6862 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
6863 For example the following two methods can be used to enable
6864 layout checking:
6865
6866 @itemize @bullet
6867 @item
6868 @smallexample @c ada
6869 pragma Style_Checks ("l");
6870 @end smallexample
6871
6872 @item
6873 @smallexample
6874 gcc -c -gnatyl @dots{}
6875 @end smallexample
6876 @end itemize
6877
6878 @noindent
6879 The form ALL_CHECKS activates all standard checks (its use is equivalent
6880 to the use of the @code{gnaty} switch with no options. @xref{Top,
6881 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
6882 @value{EDITION} User's Guide}, for details.)
6883
6884 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
6885 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
6886 options (i.e. equivalent to -gnatyg).
6887
6888 The forms with @code{Off} and @code{On}
6889 can be used to temporarily disable style checks
6890 as shown in the following example:
6891
6892 @smallexample @c ada
6893 @iftex
6894 @leftskip=0cm
6895 @end iftex
6896 pragma Style_Checks ("k"); -- requires keywords in lower case
6897 pragma Style_Checks (Off); -- turn off style checks
6898 NULL; -- this will not generate an error message
6899 pragma Style_Checks (On); -- turn style checks back on
6900 NULL; -- this will generate an error message
6901 @end smallexample
6902
6903 @noindent
6904 Finally the two argument form is allowed only if the first argument is
6905 @code{On} or @code{Off}. The effect is to turn of semantic style checks
6906 for the specified entity, as shown in the following example:
6907
6908 @smallexample @c ada
6909 @iftex
6910 @leftskip=0cm
6911 @end iftex
6912 pragma Style_Checks ("r"); -- require consistency of identifier casing
6913 Arg : Integer;
6914 Rf1 : Integer := ARG; -- incorrect, wrong case
6915 pragma Style_Checks (Off, Arg);
6916 Rf2 : Integer := ARG; -- OK, no error
6917 @end smallexample
6918
6919 @node Pragma Subtitle
6920 @unnumberedsec Pragma Subtitle
6921 @findex Subtitle
6922 @noindent
6923 Syntax:
6924
6925 @smallexample @c ada
6926 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
6927 @end smallexample
6928
6929 @noindent
6930 This pragma is recognized for compatibility with other Ada compilers
6931 but is ignored by GNAT@.
6932
6933 @node Pragma Suppress
6934 @unnumberedsec Pragma Suppress
6935 @findex Suppress
6936 @noindent
6937 Syntax:
6938
6939 @smallexample @c ada
6940 pragma Suppress (Identifier [, [On =>] Name]);
6941 @end smallexample
6942
6943 @noindent
6944 This is a standard pragma, and supports all the check names required in
6945 the RM. It is included here because GNAT recognizes some additional check
6946 names that are implementation defined (as permitted by the RM):
6947
6948 @itemize @bullet
6949
6950 @item
6951 @code{Alignment_Check} can be used to suppress alignment checks
6952 on addresses used in address clauses. Such checks can also be suppressed
6953 by suppressing range checks, but the specific use of @code{Alignment_Check}
6954 allows suppression of alignment checks without suppressing other range checks.
6955
6956 @item
6957 @code{Atomic_Synchronization} can be used to suppress the special memory
6958 synchronization instructions that are normally generated for access to
6959 @code{Atomic} variables to ensure correct synchronization between tasks
6960 that use such variables for synchronization purposes.
6961
6962 @item
6963 @code{Duplicated_Tag_Check} Can be used to suppress the check that is generated
6964 for a duplicated tag value when a tagged type is declared.
6965
6966 @item
6967 @code{Predicate_Check} can be used to control whether predicate checks are
6968 active. It is applicable only to predicates for which the policy is
6969 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
6970 predicate is ignored or checked for the whole program, the use of
6971 @code{Suppress} and @code{Unsuppress} with this check name allows a given
6972 predicate to be turned on and off at specific points in the program.
6973
6974 @item
6975 @code{Validity_Check} can be used specifically to control validity checks.
6976 If @code{Suppress} is used to suppress validity checks, then no validity
6977 checks are performed, including those specified by the appropriate compiler
6978 switch or the @code{Validity_Checks} pragma.
6979
6980 @item
6981 Additional check names previously introduced by use of the @code{Check_Name}
6982 pragma are also allowed.
6983
6984 @end itemize
6985
6986 @noindent
6987 Note that pragma Suppress gives the compiler permission to omit
6988 checks, but does not require the compiler to omit checks. The compiler
6989 will generate checks if they are essentially free, even when they are
6990 suppressed. In particular, if the compiler can prove that a certain
6991 check will necessarily fail, it will generate code to do an
6992 unconditional ``raise'', even if checks are suppressed. The compiler
6993 warns in this case.
6994
6995 Of course, run-time checks are omitted whenever the compiler can prove
6996 that they will not fail, whether or not checks are suppressed.
6997
6998 @node Pragma Suppress_All
6999 @unnumberedsec Pragma Suppress_All
7000 @findex Suppress_All
7001 @noindent
7002 Syntax:
7003
7004 @smallexample @c ada
7005 pragma Suppress_All;
7006 @end smallexample
7007
7008 @noindent
7009 This pragma can appear anywhere within a unit.
7010 The effect is to apply @code{Suppress (All_Checks)} to the unit
7011 in which it appears. This pragma is implemented for compatibility with DEC
7012 Ada 83 usage where it appears at the end of a unit, and for compatibility
7013 with Rational Ada, where it appears as a program unit pragma.
7014 The use of the standard Ada pragma @code{Suppress (All_Checks)}
7015 as a normal configuration pragma is the preferred usage in GNAT@.
7016
7017 @node Pragma Suppress_Debug_Info
7018 @unnumberedsec Pragma Suppress_Debug_Info
7019 @findex Suppress_Debug_Info
7020 @noindent
7021 Syntax:
7022
7023 @smallexample @c ada
7024 Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
7025 @end smallexample
7026
7027 @noindent
7028 This pragma can be used to suppress generation of debug information
7029 for the specified entity. It is intended primarily for use in debugging
7030 the debugger, and navigating around debugger problems.
7031
7032 @node Pragma Suppress_Exception_Locations
7033 @unnumberedsec Pragma Suppress_Exception_Locations
7034 @findex Suppress_Exception_Locations
7035 @noindent
7036 Syntax:
7037
7038 @smallexample @c ada
7039 pragma Suppress_Exception_Locations;
7040 @end smallexample
7041
7042 @noindent
7043 In normal mode, a raise statement for an exception by default generates
7044 an exception message giving the file name and line number for the location
7045 of the raise. This is useful for debugging and logging purposes, but this
7046 entails extra space for the strings for the messages. The configuration
7047 pragma @code{Suppress_Exception_Locations} can be used to suppress the
7048 generation of these strings, with the result that space is saved, but the
7049 exception message for such raises is null. This configuration pragma may
7050 appear in a global configuration pragma file, or in a specific unit as
7051 usual. It is not required that this pragma be used consistently within
7052 a partition, so it is fine to have some units within a partition compiled
7053 with this pragma and others compiled in normal mode without it.
7054
7055 @node Pragma Suppress_Initialization
7056 @unnumberedsec Pragma Suppress_Initialization
7057 @findex Suppress_Initialization
7058 @cindex Suppressing initialization
7059 @cindex Initialization, suppression of
7060 @noindent
7061 Syntax:
7062
7063 @smallexample @c ada
7064 pragma Suppress_Initialization ([Entity =>] subtype_Name);
7065 @end smallexample
7066
7067 @noindent
7068 Here subtype_Name is the name introduced by a type declaration
7069 or subtype declaration.
7070 This pragma suppresses any implicit or explicit initialization
7071 for all variables of the given type or subtype,
7072 including initialization resulting from the use of pragmas
7073 Normalize_Scalars or Initialize_Scalars.
7074
7075 This is considered a representation item, so it cannot be given after
7076 the type is frozen. It applies to all subsequent object declarations,
7077 and also any allocator that creates objects of the type.
7078
7079 If the pragma is given for the first subtype, then it is considered
7080 to apply to the base type and all its subtypes. If the pragma is given
7081 for other than a first subtype, then it applies only to the given subtype.
7082 The pragma may not be given after the type is frozen.
7083
7084 Note that this includes eliminating initialization of discriminants
7085 for discriminated types, and tags for tagged types. In these cases,
7086 you will have to use some non-portable mechanism (e.g. address
7087 overlays or unchecked conversion) to achieve required initialization
7088 of these fields before accessing any object of the corresponding type.
7089
7090 @node Pragma Task_Name
7091 @unnumberedsec Pragma Task_Name
7092 @findex Task_Name
7093 @noindent
7094 Syntax
7095
7096 @smallexample @c ada
7097 pragma Task_Name (string_EXPRESSION);
7098 @end smallexample
7099
7100 @noindent
7101 This pragma appears within a task definition (like pragma
7102 @code{Priority}) and applies to the task in which it appears. The
7103 argument must be of type String, and provides a name to be used for
7104 the task instance when the task is created. Note that this expression
7105 is not required to be static, and in particular, it can contain
7106 references to task discriminants. This facility can be used to
7107 provide different names for different tasks as they are created,
7108 as illustrated in the example below.
7109
7110 The task name is recorded internally in the run-time structures
7111 and is accessible to tools like the debugger. In addition the
7112 routine @code{Ada.Task_Identification.Image} will return this
7113 string, with a unique task address appended.
7114
7115 @smallexample @c ada
7116 -- Example of the use of pragma Task_Name
7117
7118 with Ada.Task_Identification;
7119 use Ada.Task_Identification;
7120 with Text_IO; use Text_IO;
7121 procedure t3 is
7122
7123 type Astring is access String;
7124
7125 task type Task_Typ (Name : access String) is
7126 pragma Task_Name (Name.all);
7127 end Task_Typ;
7128
7129 task body Task_Typ is
7130 Nam : constant String := Image (Current_Task);
7131 begin
7132 Put_Line ("-->" & Nam (1 .. 14) & "<--");
7133 end Task_Typ;
7134
7135 type Ptr_Task is access Task_Typ;
7136 Task_Var : Ptr_Task;
7137
7138 begin
7139 Task_Var :=
7140 new Task_Typ (new String'("This is task 1"));
7141 Task_Var :=
7142 new Task_Typ (new String'("This is task 2"));
7143 end;
7144 @end smallexample
7145
7146 @node Pragma Task_Storage
7147 @unnumberedsec Pragma Task_Storage
7148 @findex Task_Storage
7149 Syntax:
7150
7151 @smallexample @c ada
7152 pragma Task_Storage (
7153 [Task_Type =>] LOCAL_NAME,
7154 [Top_Guard =>] static_integer_EXPRESSION);
7155 @end smallexample
7156
7157 @noindent
7158 This pragma specifies the length of the guard area for tasks. The guard
7159 area is an additional storage area allocated to a task. A value of zero
7160 means that either no guard area is created or a minimal guard area is
7161 created, depending on the target. This pragma can appear anywhere a
7162 @code{Storage_Size} attribute definition clause is allowed for a task
7163 type.
7164
7165 @node Pragma Test_Case
7166 @unnumberedsec Pragma Test_Case
7167 @cindex Test cases
7168 @findex Test_Case
7169 @noindent
7170 Syntax:
7171
7172 @smallexample @c ada
7173 pragma Test_Case (
7174 [Name =>] static_string_Expression
7175 ,[Mode =>] (Nominal | Robustness)
7176 [, Requires => Boolean_Expression]
7177 [, Ensures => Boolean_Expression]);
7178 @end smallexample
7179
7180 @noindent
7181 The @code{Test_Case} pragma allows defining fine-grain specifications
7182 for use by testing tools.
7183 The compiler checks the validity of the @code{Test_Case} pragma, but its
7184 presence does not lead to any modification of the code generated by the
7185 compiler.
7186
7187 @code{Test_Case} pragmas may only appear immediately following the
7188 (separate) declaration of a subprogram in a package declaration, inside
7189 a package spec unit. Only other pragmas may intervene (that is appear
7190 between the subprogram declaration and a test case).
7191
7192 The compiler checks that boolean expressions given in @code{Requires} and
7193 @code{Ensures} are valid, where the rules for @code{Requires} are the
7194 same as the rule for an expression in @code{Precondition} and the rules
7195 for @code{Ensures} are the same as the rule for an expression in
7196 @code{Postcondition}. In particular, attributes @code{'Old} and
7197 @code{'Result} can only be used within the @code{Ensures}
7198 expression. The following is an example of use within a package spec:
7199
7200 @smallexample @c ada
7201 package Math_Functions is
7202 ...
7203 function Sqrt (Arg : Float) return Float;
7204 pragma Test_Case (Name => "Test 1",
7205 Mode => Nominal,
7206 Requires => Arg < 10000,
7207 Ensures => Sqrt'Result < 10);
7208 ...
7209 end Math_Functions;
7210 @end smallexample
7211
7212 @noindent
7213 The meaning of a test case is that there is at least one context where
7214 @code{Requires} holds such that, if the associated subprogram is executed in
7215 that context, then @code{Ensures} holds when the subprogram returns.
7216 Mode @code{Nominal} indicates that the input context should also satisfy the
7217 precondition of the subprogram, and the output context should also satisfy its
7218 postcondition. Mode @code{Robustness} indicates that the precondition and
7219 postcondition of the subprogram should be ignored for this test case.
7220
7221 @node Pragma Thread_Local_Storage
7222 @unnumberedsec Pragma Thread_Local_Storage
7223 @findex Thread_Local_Storage
7224 @cindex Task specific storage
7225 @cindex TLS (Thread Local Storage)
7226 @cindex Task_Attributes
7227 Syntax:
7228
7229 @smallexample @c ada
7230 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
7231 @end smallexample
7232
7233 @noindent
7234 This pragma specifies that the specified entity, which must be
7235 a variable declared in a library level package, is to be marked as
7236 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
7237 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
7238 (and hence each Ada task) to see a distinct copy of the variable.
7239
7240 The variable may not have default initialization, and if there is
7241 an explicit initialization, it must be either @code{null} for an
7242 access variable, or a static expression for a scalar variable.
7243 This provides a low level mechanism similar to that provided by
7244 the @code{Ada.Task_Attributes} package, but much more efficient
7245 and is also useful in writing interface code that will interact
7246 with foreign threads.
7247
7248 If this pragma is used on a system where @code{TLS} is not supported,
7249 then an error message will be generated and the program will be rejected.
7250
7251 @node Pragma Time_Slice
7252 @unnumberedsec Pragma Time_Slice
7253 @findex Time_Slice
7254 @noindent
7255 Syntax:
7256
7257 @smallexample @c ada
7258 pragma Time_Slice (static_duration_EXPRESSION);
7259 @end smallexample
7260
7261 @noindent
7262 For implementations of GNAT on operating systems where it is possible
7263 to supply a time slice value, this pragma may be used for this purpose.
7264 It is ignored if it is used in a system that does not allow this control,
7265 or if it appears in other than the main program unit.
7266 @cindex OpenVMS
7267 Note that the effect of this pragma is identical to the effect of the
7268 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
7269
7270 @node Pragma Title
7271 @unnumberedsec Pragma Title
7272 @findex Title
7273 @noindent
7274 Syntax:
7275
7276 @smallexample @c ada
7277 pragma Title (TITLING_OPTION [, TITLING OPTION]);
7278
7279 TITLING_OPTION ::=
7280 [Title =>] STRING_LITERAL,
7281 | [Subtitle =>] STRING_LITERAL
7282 @end smallexample
7283
7284 @noindent
7285 Syntax checked but otherwise ignored by GNAT@. This is a listing control
7286 pragma used in DEC Ada 83 implementations to provide a title and/or
7287 subtitle for the program listing. The program listing generated by GNAT
7288 does not have titles or subtitles.
7289
7290 Unlike other pragmas, the full flexibility of named notation is allowed
7291 for this pragma, i.e.@: the parameters may be given in any order if named
7292 notation is used, and named and positional notation can be mixed
7293 following the normal rules for procedure calls in Ada.
7294
7295 @node Pragma Type_Invariant
7296 @unnumberedsec Pragma Type_Invariant
7297 @findex Invariant
7298 @findex Type_Invariant pragma
7299 @noindent
7300 Syntax:
7301
7302 @smallexample @c ada
7303 pragma Type_Invariant
7304 ([Entity =>] type_LOCAL_NAME,
7305 [Check =>] EXPRESSION);
7306 @end smallexample
7307
7308 @noindent
7309 The @code{Type_Invariant} pragma is intended to be an exact
7310 replacement for the language-defined @code{Type_Invariant}
7311 aspect, and shares its restrictions and semantics. It differs
7312 from the language defined @code{Invariant} pragma in that it
7313 does not permit a string parameter, and it is
7314 controlled by the assertion identifier @code{Type_Invariant}
7315 rather than @code{Invariant}.
7316
7317 @node Pragma Type_Invariant_Class
7318 @unnumberedsec Pragma Type_Invariant_Class
7319 @findex Invariant
7320 @findex Type_Invariant_Class pragma
7321 @noindent
7322 Syntax:
7323
7324 @smallexample @c ada
7325 pragma Type_Invariant_Class
7326 ([Entity =>] type_LOCAL_NAME,
7327 [Check =>] EXPRESSION);
7328 @end smallexample
7329
7330 @noindent
7331 The @code{Type_Invariant_Class} pragma is intended to be an exact
7332 replacement for the language-defined @code{Type_Invariant'Class}
7333 aspect, and shares its restrictions and semantics.
7334
7335 Note: This pragma is called @code{Type_Invariant_Class} rather than
7336 @code{Type_Invariant'Class} because the latter would not be strictly
7337 conforming to the allowed syntax for pragmas. The motivation
7338 for providing pragmas equivalent to the aspects is to allow a program
7339 to be written using the pragmas, and then compiled if necessary
7340 using an Ada compiler that does not recognize the pragmas or
7341 aspects, but is prepared to ignore the pragmas. The assertion
7342 policy that controls this pragma is @code{Type_Invariant'Class},
7343 not @code{Type_Invariant_Class}.
7344
7345 @node Pragma Unchecked_Union
7346 @unnumberedsec Pragma Unchecked_Union
7347 @cindex Unions in C
7348 @findex Unchecked_Union
7349 @noindent
7350 Syntax:
7351
7352 @smallexample @c ada
7353 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
7354 @end smallexample
7355
7356 @noindent
7357 This pragma is used to specify a representation of a record type that is
7358 equivalent to a C union. It was introduced as a GNAT implementation defined
7359 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
7360 pragma, making it language defined, and GNAT fully implements this extended
7361 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
7362 details, consult the Ada 2012 Reference Manual, section B.3.3.
7363
7364 @node Pragma Unevaluated_Use_Of_Old
7365 @unnumberedsec Pragma Unevaluated_Use_Of_Old
7366 @cindex Attribute Old
7367 @cindex Attribute Loop_Entry
7368 @cindex Unevaluated_Use_Of_Old
7369 @findex Unevaluated_Use_Of_Old
7370 @noindent
7371 Syntax:
7372
7373 @smallexample @c ada
7374 pragma Unevaluated_Use_Of_Old (Error | Warn | Allow);
7375 @end smallexample
7376
7377 @noindent
7378 This pragma controls the processing of attributes Old and Loop_Entry.
7379 If either of these attributes is used in a potentially unevaluated
7380 expression (e.g. the then or else parts of an if expression), then
7381 normally this usage is considered illegal if the prefix of the attribute
7382 is other than an entity name. The language requires this
7383 behavior for Old, and GNAT copies the same rule for Loop_Entry.
7384
7385 The reason for this rule is that otherwise, we can have a situation
7386 where we save the Old value, and this results in an exception, even
7387 though we might not evaluate the attribute. Consider this example:
7388
7389 @smallexample @c ada
7390 package UnevalOld is
7391 K : Character;
7392 procedure U (A : String; C : Boolean) -- ERROR
7393 with Post => (if C then A(1)'Old = K else True);
7394 end;
7395 @end smallexample
7396
7397 @noindent
7398 If procedure U is called with a string with a lower bound of 2, and
7399 C false, then an exception would be raised trying to evaluate A(1)
7400 on entry even though the value would not be actually used.
7401
7402 Although the rule guarantees against this possibility, it is sometimes
7403 too restrictive. For example if we know that the string has a lower
7404 bound of 1, then we will never raise an exception.
7405 The pragma @code{Unevaluated_Use_Of_Old} can be
7406 used to modify this behavior. If the argument is @code{Error} then an
7407 error is given (this is the default RM behavior). If the argument is
7408 @code{Warn} then the usage is allowed as legal but with a warning
7409 that an exception might be raised. If the argument is @code{Allow}
7410 then the usage is allowed as legal without generating a warning.
7411
7412 This pragma may appear as a configuration pragma, or in a declarative
7413 part or package specification. In the latter case it applies to
7414 uses up to the end of the corresponding statement sequence or
7415 sequence of package declarations.
7416
7417 @node Pragma Unimplemented_Unit
7418 @unnumberedsec Pragma Unimplemented_Unit
7419 @findex Unimplemented_Unit
7420 @noindent
7421 Syntax:
7422
7423 @smallexample @c ada
7424 pragma Unimplemented_Unit;
7425 @end smallexample
7426
7427 @noindent
7428 If this pragma occurs in a unit that is processed by the compiler, GNAT
7429 aborts with the message @samp{@var{xxx} not implemented}, where
7430 @var{xxx} is the name of the current compilation unit. This pragma is
7431 intended to allow the compiler to handle unimplemented library units in
7432 a clean manner.
7433
7434 The abort only happens if code is being generated. Thus you can use
7435 specs of unimplemented packages in syntax or semantic checking mode.
7436
7437 @node Pragma Universal_Aliasing
7438 @unnumberedsec Pragma Universal_Aliasing
7439 @findex Universal_Aliasing
7440 @noindent
7441 Syntax:
7442
7443 @smallexample @c ada
7444 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
7445 @end smallexample
7446
7447 @noindent
7448 @var{type_LOCAL_NAME} must refer to a type declaration in the current
7449 declarative part. The effect is to inhibit strict type-based aliasing
7450 optimization for the given type. In other words, the effect is as though
7451 access types designating this type were subject to pragma No_Strict_Aliasing.
7452 For a detailed description of the strict aliasing optimization, and the
7453 situations in which it must be suppressed, @xref{Optimization and Strict
7454 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
7455
7456 @node Pragma Universal_Data
7457 @unnumberedsec Pragma Universal_Data
7458 @findex Universal_Data
7459 @noindent
7460 Syntax:
7461
7462 @smallexample @c ada
7463 pragma Universal_Data [(library_unit_Name)];
7464 @end smallexample
7465
7466 @noindent
7467 This pragma is supported only for the AAMP target and is ignored for
7468 other targets. The pragma specifies that all library-level objects
7469 (Counter 0 data) associated with the library unit are to be accessed
7470 and updated using universal addressing (24-bit addresses for AAMP5)
7471 rather than the default of 16-bit Data Environment (DENV) addressing.
7472 Use of this pragma will generally result in less efficient code for
7473 references to global data associated with the library unit, but
7474 allows such data to be located anywhere in memory. This pragma is
7475 a library unit pragma, but can also be used as a configuration pragma
7476 (including use in the @file{gnat.adc} file). The functionality
7477 of this pragma is also available by applying the -univ switch on the
7478 compilations of units where universal addressing of the data is desired.
7479
7480 @node Pragma Unmodified
7481 @unnumberedsec Pragma Unmodified
7482 @findex Unmodified
7483 @cindex Warnings, unmodified
7484 @noindent
7485 Syntax:
7486
7487 @smallexample @c ada
7488 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
7489 @end smallexample
7490
7491 @noindent
7492 This pragma signals that the assignable entities (variables,
7493 @code{out} parameters, @code{in out} parameters) whose names are listed are
7494 deliberately not assigned in the current source unit. This
7495 suppresses warnings about the
7496 entities being referenced but not assigned, and in addition a warning will be
7497 generated if one of these entities is in fact assigned in the
7498 same unit as the pragma (or in the corresponding body, or one
7499 of its subunits).
7500
7501 This is particularly useful for clearly signaling that a particular
7502 parameter is not modified, even though the spec suggests that it might
7503 be.
7504
7505 For the variable case, warnings are never given for unreferenced variables
7506 whose name contains one of the substrings
7507 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7508 are typically to be used in cases where such warnings are expected.
7509 Thus it is never necessary to use @code{pragma Unmodified} for such
7510 variables, though it is harmless to do so.
7511
7512 @node Pragma Unreferenced
7513 @unnumberedsec Pragma Unreferenced
7514 @findex Unreferenced
7515 @cindex Warnings, unreferenced
7516 @noindent
7517 Syntax:
7518
7519 @smallexample @c ada
7520 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
7521 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
7522 @end smallexample
7523
7524 @noindent
7525 This pragma signals that the entities whose names are listed are
7526 deliberately not referenced in the current source unit after the
7527 occurrence of the pragma. This
7528 suppresses warnings about the
7529 entities being unreferenced, and in addition a warning will be
7530 generated if one of these entities is in fact subsequently referenced in the
7531 same unit as the pragma (or in the corresponding body, or one
7532 of its subunits).
7533
7534 This is particularly useful for clearly signaling that a particular
7535 parameter is not referenced in some particular subprogram implementation
7536 and that this is deliberate. It can also be useful in the case of
7537 objects declared only for their initialization or finalization side
7538 effects.
7539
7540 If @code{LOCAL_NAME} identifies more than one matching homonym in the
7541 current scope, then the entity most recently declared is the one to which
7542 the pragma applies. Note that in the case of accept formals, the pragma
7543 Unreferenced may appear immediately after the keyword @code{do} which
7544 allows the indication of whether or not accept formals are referenced
7545 or not to be given individually for each accept statement.
7546
7547 The left hand side of an assignment does not count as a reference for the
7548 purpose of this pragma. Thus it is fine to assign to an entity for which
7549 pragma Unreferenced is given.
7550
7551 Note that if a warning is desired for all calls to a given subprogram,
7552 regardless of whether they occur in the same unit as the subprogram
7553 declaration, then this pragma should not be used (calls from another
7554 unit would not be flagged); pragma Obsolescent can be used instead
7555 for this purpose, see @xref{Pragma Obsolescent}.
7556
7557 The second form of pragma @code{Unreferenced} is used within a context
7558 clause. In this case the arguments must be unit names of units previously
7559 mentioned in @code{with} clauses (similar to the usage of pragma
7560 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
7561 units and unreferenced entities within these units.
7562
7563 For the variable case, warnings are never given for unreferenced variables
7564 whose name contains one of the substrings
7565 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
7566 are typically to be used in cases where such warnings are expected.
7567 Thus it is never necessary to use @code{pragma Unreferenced} for such
7568 variables, though it is harmless to do so.
7569
7570 @node Pragma Unreferenced_Objects
7571 @unnumberedsec Pragma Unreferenced_Objects
7572 @findex Unreferenced_Objects
7573 @cindex Warnings, unreferenced
7574 @noindent
7575 Syntax:
7576
7577 @smallexample @c ada
7578 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
7579 @end smallexample
7580
7581 @noindent
7582 This pragma signals that for the types or subtypes whose names are
7583 listed, objects which are declared with one of these types or subtypes may
7584 not be referenced, and if no references appear, no warnings are given.
7585
7586 This is particularly useful for objects which are declared solely for their
7587 initialization and finalization effect. Such variables are sometimes referred
7588 to as RAII variables (Resource Acquisition Is Initialization). Using this
7589 pragma on the relevant type (most typically a limited controlled type), the
7590 compiler will automatically suppress unwanted warnings about these variables
7591 not being referenced.
7592
7593 @node Pragma Unreserve_All_Interrupts
7594 @unnumberedsec Pragma Unreserve_All_Interrupts
7595 @findex Unreserve_All_Interrupts
7596 @noindent
7597 Syntax:
7598
7599 @smallexample @c ada
7600 pragma Unreserve_All_Interrupts;
7601 @end smallexample
7602
7603 @noindent
7604 Normally certain interrupts are reserved to the implementation. Any attempt
7605 to attach an interrupt causes Program_Error to be raised, as described in
7606 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
7607 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
7608 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
7609 interrupt execution.
7610
7611 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
7612 a program, then all such interrupts are unreserved. This allows the
7613 program to handle these interrupts, but disables their standard
7614 functions. For example, if this pragma is used, then pressing
7615 @kbd{Ctrl-C} will not automatically interrupt execution. However,
7616 a program can then handle the @code{SIGINT} interrupt as it chooses.
7617
7618 For a full list of the interrupts handled in a specific implementation,
7619 see the source code for the spec of @code{Ada.Interrupts.Names} in
7620 file @file{a-intnam.ads}. This is a target dependent file that contains the
7621 list of interrupts recognized for a given target. The documentation in
7622 this file also specifies what interrupts are affected by the use of
7623 the @code{Unreserve_All_Interrupts} pragma.
7624
7625 For a more general facility for controlling what interrupts can be
7626 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
7627 of the @code{Unreserve_All_Interrupts} pragma.
7628
7629 @node Pragma Unsuppress
7630 @unnumberedsec Pragma Unsuppress
7631 @findex Unsuppress
7632 @noindent
7633 Syntax:
7634
7635 @smallexample @c ada
7636 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
7637 @end smallexample
7638
7639 @noindent
7640 This pragma undoes the effect of a previous pragma @code{Suppress}. If
7641 there is no corresponding pragma @code{Suppress} in effect, it has no
7642 effect. The range of the effect is the same as for pragma
7643 @code{Suppress}. The meaning of the arguments is identical to that used
7644 in pragma @code{Suppress}.
7645
7646 One important application is to ensure that checks are on in cases where
7647 code depends on the checks for its correct functioning, so that the code
7648 will compile correctly even if the compiler switches are set to suppress
7649 checks. For example, in a program that depends on external names of tagged
7650 types and wants to ensure that the duplicated tag check occurs even if all
7651 run-time checks are suppressed by a compiler switch, the following
7652 configuration pragma will ensure this test is not suppressed:
7653
7654 @smallexample @c ada
7655 pragma Unsuppress (Duplicated_Tag_Check);
7656 @end smallexample
7657
7658 @noindent
7659 This pragma is standard in Ada 2005. It is available in all earlier versions
7660 of Ada as an implementation-defined pragma.
7661
7662 Note that in addition to the checks defined in the Ada RM, GNAT recogizes
7663 a number of implementation-defined check names. See description of pragma
7664 @code{Suppress} for full details.
7665
7666 @node Pragma Use_VADS_Size
7667 @unnumberedsec Pragma Use_VADS_Size
7668 @cindex @code{Size}, VADS compatibility
7669 @cindex Rational profile
7670 @findex Use_VADS_Size
7671 @noindent
7672 Syntax:
7673
7674 @smallexample @c ada
7675 pragma Use_VADS_Size;
7676 @end smallexample
7677
7678 @noindent
7679 This is a configuration pragma. In a unit to which it applies, any use
7680 of the 'Size attribute is automatically interpreted as a use of the
7681 'VADS_Size attribute. Note that this may result in incorrect semantic
7682 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
7683 the handling of existing code which depends on the interpretation of Size
7684 as implemented in the VADS compiler. See description of the VADS_Size
7685 attribute for further details.
7686
7687 @node Pragma Validity_Checks
7688 @unnumberedsec Pragma Validity_Checks
7689 @findex Validity_Checks
7690 @noindent
7691 Syntax:
7692
7693 @smallexample @c ada
7694 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
7695 @end smallexample
7696
7697 @noindent
7698 This pragma is used in conjunction with compiler switches to control the
7699 built-in validity checking provided by GNAT@. The compiler switches, if set
7700 provide an initial setting for the switches, and this pragma may be used
7701 to modify these settings, or the settings may be provided entirely by
7702 the use of the pragma. This pragma can be used anywhere that a pragma
7703 is legal, including use as a configuration pragma (including use in
7704 the @file{gnat.adc} file).
7705
7706 The form with a string literal specifies which validity options are to be
7707 activated. The validity checks are first set to include only the default
7708 reference manual settings, and then a string of letters in the string
7709 specifies the exact set of options required. The form of this string
7710 is exactly as described for the @option{-gnatVx} compiler switch (see the
7711 @value{EDITION} User's Guide for details). For example the following two
7712 methods can be used to enable validity checking for mode @code{in} and
7713 @code{in out} subprogram parameters:
7714
7715 @itemize @bullet
7716 @item
7717 @smallexample @c ada
7718 pragma Validity_Checks ("im");
7719 @end smallexample
7720
7721 @item
7722 @smallexample
7723 gcc -c -gnatVim @dots{}
7724 @end smallexample
7725 @end itemize
7726
7727 @noindent
7728 The form ALL_CHECKS activates all standard checks (its use is equivalent
7729 to the use of the @code{gnatva} switch.
7730
7731 The forms with @code{Off} and @code{On}
7732 can be used to temporarily disable validity checks
7733 as shown in the following example:
7734
7735 @smallexample @c ada
7736 @iftex
7737 @leftskip=0cm
7738 @end iftex
7739 pragma Validity_Checks ("c"); -- validity checks for copies
7740 pragma Validity_Checks (Off); -- turn off validity checks
7741 A := B; -- B will not be validity checked
7742 pragma Validity_Checks (On); -- turn validity checks back on
7743 A := C; -- C will be validity checked
7744 @end smallexample
7745
7746 @node Pragma Volatile
7747 @unnumberedsec Pragma Volatile
7748 @findex Volatile
7749 @noindent
7750 Syntax:
7751
7752 @smallexample @c ada
7753 pragma Volatile (LOCAL_NAME);
7754 @end smallexample
7755
7756 @noindent
7757 This pragma is defined by the Ada Reference Manual, and the GNAT
7758 implementation is fully conformant with this definition. The reason it
7759 is mentioned in this section is that a pragma of the same name was supplied
7760 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
7761 implementation of pragma Volatile is upwards compatible with the
7762 implementation in DEC Ada 83.
7763
7764 @node Pragma Warning_As_Error
7765 @unnumberedsec Pragma Warning_As_Error
7766 @findex Warning_As_Error
7767 @noindent
7768 Syntax:
7769
7770 @smallexample @c ada
7771 pragma Warning_As_Error (static_string_EXPRESSION);
7772 @end smallexample
7773
7774 @noindent
7775 This configuration pragma allows the programmer to specify a set
7776 of warnings that will be treated as errors. Any warning which
7777 matches the pattern given by the pragma argument will be treated
7778 as an error. This gives much more precise control that -gnatwe
7779 which treats all warnings as errors.
7780
7781 The pattern may contain asterisks, which match zero or more characters in
7782 the message. For example, you can use
7783 @code{pragma Warning_As_Error ("bits of*unused")} to treat the warning
7784 message @code{warning: 960 bits of "a" unused} as an error. No other regular
7785 expression notations are permitted. All characters other than asterisk in
7786 these three specific cases are treated as literal characters in the match.
7787 The match is case insensitive, for example XYZ matches xyz.
7788
7789 Note that the pattern matches if it occurs anywhere within the warning
7790 message string (it is not necessary to put an asterisk at the start and
7791 the end of the message, since this is implied).
7792
7793 Another possibility for the static_string_EXPRESSION which works whether
7794 or not error tags are enabled (@option{-gnatw.d}) is to use the
7795 @option{-gnatw} tag string, enclosed in brackets,
7796 as shown in the example below, to treat a class of warnings as errors.
7797
7798 The above use of patterns to match the message applies only to warning
7799 messages generated by the front end. This pragma can also be applied to
7800 warnings provided by the back end and mentioned in @ref{Pragma Warnings}.
7801 By using a single full @option{-Wxxx} switch in the pragma, such warnings
7802 can also be treated as errors.
7803
7804 The pragma can appear either in a global configuration pragma file
7805 (e.g. @file{gnat.adc}), or at the start of a file. Given a global
7806 configuration pragma file containing:
7807
7808 @smallexample @c ada
7809 pragma Warning_As_Error ("[-gnatwj]");
7810 @end smallexample
7811
7812 @noindent
7813 which will treat all obsolescent feature warnings as errors, the
7814 following program compiles as shown (compile options here are
7815 @option{-gnatwa.d -gnatl -gnatj55}).
7816
7817 @smallexample @c ada
7818 1. pragma Warning_As_Error ("*never assigned*");
7819 2. function Warnerr return String is
7820 3. X : Integer;
7821 |
7822 >>> error: variable "X" is never read and
7823 never assigned [-gnatwv] [warning-as-error]
7824
7825 4. Y : Integer;
7826 |
7827 >>> warning: variable "Y" is assigned but
7828 never read [-gnatwu]
7829
7830 5. begin
7831 6. Y := 0;
7832 7. return %ABC%;
7833 |
7834 >>> error: use of "%" is an obsolescent
7835 feature (RM J.2(4)), use """ instead
7836 [-gnatwj] [warning-as-error]
7837
7838 8. end;
7839
7840 8 lines: No errors, 3 warnings (2 treated as errors)
7841 @end smallexample
7842
7843 @noindent
7844 Note that this pragma does not affect the set of warnings issued in
7845 any way, it merely changes the effect of a matching warning if one
7846 is produced as a result of other warnings options. As shown in this
7847 example, if the pragma results in a warning being treated as an error,
7848 the tag is changed from "warning:" to "error:" and the string
7849 "[warning-as-error]" is appended to the end of the message.
7850
7851 @node Pragma Warnings
7852 @unnumberedsec Pragma Warnings
7853 @findex Warnings
7854 @noindent
7855 Syntax:
7856
7857 @smallexample @c ada
7858 pragma Warnings (On | Off [,REASON]);
7859 pragma Warnings (On | Off, LOCAL_NAME [,REASON]);
7860 pragma Warnings (static_string_EXPRESSION [,REASON]);
7861 pragma Warnings (On | Off, static_string_EXPRESSION [,REASON]);
7862
7863 REASON ::= Reason => STRING_LITERAL @{& STRING_LITERAL@}
7864 @end smallexample
7865
7866 @noindent
7867 Normally warnings are enabled, with the output being controlled by
7868 the command line switch. Warnings (@code{Off}) turns off generation of
7869 warnings until a Warnings (@code{On}) is encountered or the end of the
7870 current unit. If generation of warnings is turned off using this
7871 pragma, then some or all of the warning messages are suppressed,
7872 regardless of the setting of the command line switches.
7873
7874 The @code{Reason} parameter may optionally appear as the last argument
7875 in any of the forms of this pragma. It is intended purely for the
7876 purposes of documenting the reason for the @code{Warnings} pragma.
7877 The compiler will check that the argument is a static string but
7878 otherwise ignore this argument. Other tools may provide specialized
7879 processing for this string.
7880
7881 The form with a single argument (or two arguments if Reason present),
7882 where the first argument is @code{ON} or @code{OFF}
7883 may be used as a configuration pragma.
7884
7885 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
7886 the specified entity. This suppression is effective from the point where
7887 it occurs till the end of the extended scope of the variable (similar to
7888 the scope of @code{Suppress}). This form cannot be used as a configuration
7889 pragma.
7890
7891 The form with a single static_string_EXPRESSION argument (and possible
7892 reason) provides more precise
7893 control over which warnings are active. The string is a list of letters
7894 specifying which warnings are to be activated and which deactivated. The
7895 code for these letters is the same as the string used in the command
7896 line switch controlling warnings. For a brief summary, use the gnatmake
7897 command with no arguments, which will generate usage information containing
7898 the list of warnings switches supported. For
7899 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
7900 User's Guide}. This form can also be used as a configuration pragma.
7901
7902 @noindent
7903 The warnings controlled by the @option{-gnatw} switch are generated by the
7904 front end of the compiler. The GCC back end can provide additional warnings
7905 and they are controlled by the @option{-W} switch. Such warnings can be
7906 identified by the appearance of a string of the form @code{[-Wxxx]} in the
7907 message which designates the @option{-Wxxx} switch that controls the message.
7908 The form with a single static_string_EXPRESSION argument also works for these
7909 warnings, but the string must be a single full @option{-Wxxx} switch in this
7910 case. The above reference lists a few examples of these additional warnings.
7911
7912 @noindent
7913 The specified warnings will be in effect until the end of the program
7914 or another pragma Warnings is encountered. The effect of the pragma is
7915 cumulative. Initially the set of warnings is the standard default set
7916 as possibly modified by compiler switches. Then each pragma Warning
7917 modifies this set of warnings as specified. This form of the pragma may
7918 also be used as a configuration pragma.
7919
7920 The fourth form, with an @code{On|Off} parameter and a string, is used to
7921 control individual messages, based on their text. The string argument
7922 is a pattern that is used to match against the text of individual
7923 warning messages (not including the initial "warning: " tag).
7924
7925 The pattern may contain asterisks, which match zero or more characters in
7926 the message. For example, you can use
7927 @code{pragma Warnings (Off, "bits of*unused")} to suppress the warning
7928 message @code{warning: 960 bits of "a" unused}. No other regular
7929 expression notations are permitted. All characters other than asterisk in
7930 these three specific cases are treated as literal characters in the match.
7931 The match is case insensitive, for example XYZ matches xyz.
7932
7933 Note that the pattern matches if it occurs anywhere within the warning
7934 message string (it is not necessary to put an asterisk at the start and
7935 the end of the message, since this is implied).
7936
7937 The above use of patterns to match the message applies only to warning
7938 messages generated by the front end. This form of the pragma with a string
7939 argument can also be used to control warnings provided by the back end and
7940 mentioned above. By using a single full @option{-Wxxx} switch in the pragma,
7941 such warnings can be turned on and off.
7942
7943 There are two ways to use the pragma in this form. The OFF form can be used
7944 as a configuration pragma. The effect is to suppress all warnings (if any)
7945 that match the pattern string throughout the compilation (or match the
7946 -W switch in the back end case).
7947
7948 The second usage is to suppress a warning locally, and in this case, two
7949 pragmas must appear in sequence:
7950
7951 @smallexample @c ada
7952 pragma Warnings (Off, Pattern);
7953 @dots{} code where given warning is to be suppressed
7954 pragma Warnings (On, Pattern);
7955 @end smallexample
7956
7957 @noindent
7958 In this usage, the pattern string must match in the Off and On pragmas,
7959 and at least one matching warning must be suppressed.
7960
7961 Note: to write a string that will match any warning, use the string
7962 @code{"***"}. It will not work to use a single asterisk or two asterisks
7963 since this looks like an operator name. This form with three asterisks
7964 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
7965 matching @code{pragma Warnings (On, "***")} will be required. This can be
7966 helpful in avoiding forgetting to turn warnings back on.
7967
7968 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
7969 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
7970 be useful in checking whether obsolete pragmas in existing programs are hiding
7971 real problems.
7972
7973 Note: pragma Warnings does not affect the processing of style messages. See
7974 separate entry for pragma Style_Checks for control of style messages.
7975
7976 @node Pragma Weak_External
7977 @unnumberedsec Pragma Weak_External
7978 @findex Weak_External
7979 @noindent
7980 Syntax:
7981
7982 @smallexample @c ada
7983 pragma Weak_External ([Entity =>] LOCAL_NAME);
7984 @end smallexample
7985
7986 @noindent
7987 @var{LOCAL_NAME} must refer to an object that is declared at the library
7988 level. This pragma specifies that the given entity should be marked as a
7989 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
7990 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
7991 of a regular symbol, that is to say a symbol that does not have to be
7992 resolved by the linker if used in conjunction with a pragma Import.
7993
7994 When a weak symbol is not resolved by the linker, its address is set to
7995 zero. This is useful in writing interfaces to external modules that may
7996 or may not be linked in the final executable, for example depending on
7997 configuration settings.
7998
7999 If a program references at run time an entity to which this pragma has been
8000 applied, and the corresponding symbol was not resolved at link time, then
8001 the execution of the program is erroneous. It is not erroneous to take the
8002 Address of such an entity, for example to guard potential references,
8003 as shown in the example below.
8004
8005 Some file formats do not support weak symbols so not all target machines
8006 support this pragma.
8007
8008 @smallexample @c ada
8009 -- Example of the use of pragma Weak_External
8010
8011 package External_Module is
8012 key : Integer;
8013 pragma Import (C, key);
8014 pragma Weak_External (key);
8015 function Present return boolean;
8016 end External_Module;
8017
8018 with System; use System;
8019 package body External_Module is
8020 function Present return boolean is
8021 begin
8022 return key'Address /= System.Null_Address;
8023 end Present;
8024 end External_Module;
8025 @end smallexample
8026
8027 @node Pragma Wide_Character_Encoding
8028 @unnumberedsec Pragma Wide_Character_Encoding
8029 @findex Wide_Character_Encoding
8030 @noindent
8031 Syntax:
8032
8033 @smallexample @c ada
8034 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
8035 @end smallexample
8036
8037 @noindent
8038 This pragma specifies the wide character encoding to be used in program
8039 source text appearing subsequently. It is a configuration pragma, but may
8040 also be used at any point that a pragma is allowed, and it is permissible
8041 to have more than one such pragma in a file, allowing multiple encodings
8042 to appear within the same file.
8043
8044 The argument can be an identifier or a character literal. In the identifier
8045 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
8046 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
8047 case it is correspondingly one of the characters @samp{h}, @samp{u},
8048 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
8049
8050 Note that when the pragma is used within a file, it affects only the
8051 encoding within that file, and does not affect withed units, specs,
8052 or subunits.
8053
8054 @node Implementation Defined Aspects
8055 @chapter Implementation Defined Aspects
8056 Ada defines (throughout the Ada 2012 reference manual, summarized
8057 in Annex K) a set of aspects that can be specified for certain entities.
8058 These language defined aspects are implemented in GNAT in Ada 2012 mode
8059 and work as described in the Ada 2012 Reference Manual.
8060
8061 In addition, Ada 2012 allows implementations to define additional aspects
8062 whose meaning is defined by the implementation. GNAT provides
8063 a number of these implementation-defined aspects which can be used
8064 to extend and enhance the functionality of the compiler. This section of
8065 the GNAT reference manual describes these additional aspects.
8066
8067 Note that any program using these aspects may not be portable to
8068 other compilers (although GNAT implements this set of aspects on all
8069 platforms). Therefore if portability to other compilers is an important
8070 consideration, you should minimize the use of these aspects.
8071
8072 Note that for many of these aspects, the effect is essentially similar
8073 to the use of a pragma or attribute specification with the same name
8074 applied to the entity. For example, if we write:
8075
8076 @smallexample @c ada
8077 type R is range 1 .. 100
8078 with Value_Size => 10;
8079 @end smallexample
8080
8081 @noindent
8082 then the effect is the same as:
8083
8084 @smallexample @c ada
8085 type R is range 1 .. 100;
8086 for R'Value_Size use 10;
8087 @end smallexample
8088
8089 @noindent
8090 and if we write:
8091
8092 @smallexample @c ada
8093 type R is new Integer
8094 with Shared => True;
8095 @end smallexample
8096
8097 @noindent
8098 then the effect is the same as:
8099
8100 @smallexample @c ada
8101 type R is new Integer;
8102 pragma Shared (R);
8103 @end smallexample
8104
8105 @noindent
8106 In the documentation below, such cases are simply marked
8107 as being equivalent to the corresponding pragma or attribute definition
8108 clause.
8109
8110 @menu
8111 * Aspect Abstract_State::
8112 * Aspect Annotate::
8113 * Aspect Async_Readers::
8114 * Aspect Async_Writers::
8115 * Aspect Contract_Cases::
8116 * Aspect Depends::
8117 * Aspect Dimension::
8118 * Aspect Dimension_System::
8119 * Aspect Effective_Reads::
8120 * Aspect Effective_Writes::
8121 * Aspect Favor_Top_Level::
8122 * Aspect Global::
8123 * Aspect Initial_Condition::
8124 * Aspect Initializes::
8125 * Aspect Inline_Always::
8126 * Aspect Invariant::
8127 * Aspect Iterable::
8128 * Aspect Linker_Section::
8129 * Aspect Lock_Free::
8130 * Aspect Object_Size::
8131 * Aspect Part_Of::
8132 * Aspect Persistent_BSS::
8133 * Aspect Predicate::
8134 * Aspect Pure_Function::
8135 * Aspect Refined_Depends::
8136 * Aspect Refined_Global::
8137 * Aspect Refined_Post::
8138 * Aspect Refined_State::
8139 * Aspect Remote_Access_Type::
8140 * Aspect Scalar_Storage_Order::
8141 * Aspect Shared::
8142 * Aspect Simple_Storage_Pool::
8143 * Aspect Simple_Storage_Pool_Type::
8144 * Aspect SPARK_Mode::
8145 * Aspect Suppress_Debug_Info::
8146 * Aspect Test_Case::
8147 * Aspect Thread_Local_Storage::
8148 * Aspect Universal_Aliasing::
8149 * Aspect Universal_Data::
8150 * Aspect Unmodified::
8151 * Aspect Unreferenced::
8152 * Aspect Unreferenced_Objects::
8153 * Aspect Value_Size::
8154 * Aspect Warnings::
8155 @end menu
8156
8157 @node Aspect Abstract_State
8158 @unnumberedsec Aspect Abstract_State
8159 @findex Abstract_State
8160 @noindent
8161 This aspect is equivalent to pragma @code{Abstract_State}.
8162
8163 @node Aspect Annotate
8164 @unnumberedsec Annotate
8165 @findex Annotate
8166 @noindent
8167 There are three forms of this aspect (where ID is an identifier,
8168 and ARG is a general expression).
8169
8170 @table @code
8171 @item Annotate => ID
8172 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
8173
8174 @item Annotate => (ID)
8175 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
8176
8177 @item Annotate => (ID ,ID @{, ARG@})
8178 Equivalent to @code{pragma Annotate (ID, ID @{, ARG@}, Entity => Name);}
8179 @end table
8180
8181 @node Aspect Async_Readers
8182 @unnumberedsec Aspect Async_Readers
8183 @findex Async_Readers
8184 @noindent
8185 This aspect is equivalent to pragma @code{Async_Readers}.
8186
8187 @node Aspect Async_Writers
8188 @unnumberedsec Aspect Async_Writers
8189 @findex Async_Writers
8190 @noindent
8191 This aspect is equivalent to pragma @code{Async_Writers}.
8192
8193 @node Aspect Contract_Cases
8194 @unnumberedsec Aspect Contract_Cases
8195 @findex Contract_Cases
8196 @noindent
8197 This aspect is equivalent to pragma @code{Contract_Cases}, the sequence
8198 of clauses being enclosed in parentheses so that syntactically it is an
8199 aggregate.
8200
8201 @node Aspect Depends
8202 @unnumberedsec Aspect Depends
8203 @findex Depends
8204 @noindent
8205 This aspect is equivalent to pragma @code{Depends}.
8206
8207 @node Aspect Dimension
8208 @unnumberedsec Aspect Dimension
8209 @findex Dimension
8210 @noindent
8211 The @code{Dimension} aspect is used to specify the dimensions of a given
8212 subtype of a dimensioned numeric type. The aspect also specifies a symbol
8213 used when doing formatted output of dimensioned quantities. The syntax is:
8214
8215 @smallexample @c ada
8216 with Dimension =>
8217 ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
8218
8219 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
8220
8221 DIMENSION_VALUE ::=
8222 RATIONAL
8223 | others => RATIONAL
8224 | DISCRETE_CHOICE_LIST => RATIONAL
8225
8226 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
8227 @end smallexample
8228
8229 @noindent
8230 This aspect can only be applied to a subtype whose parent type has
8231 a @code{Dimension_Systen} aspect. The aspect must specify values for
8232 all dimensions of the system. The rational values are the powers of the
8233 corresponding dimensions that are used by the compiler to verify that
8234 physical (numeric) computations are dimensionally consistent. For example,
8235 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
8236 For further examples of the usage
8237 of this aspect, see package @code{System.Dim.Mks}.
8238 Note that when the dimensioned type is an integer type, then any
8239 dimension value must be an integer literal.
8240
8241 @node Aspect Dimension_System
8242 @unnumberedsec Aspect Dimension_System
8243 @findex Dimension_System
8244 @noindent
8245 The @code{Dimension_System} aspect is used to define a system of
8246 dimensions that will be used in subsequent subtype declarations with
8247 @code{Dimension} aspects that reference this system. The syntax is:
8248
8249 @smallexample @c ada
8250 with Dimension_System => (DIMENSION @{, DIMENSION@});
8251
8252 DIMENSION ::= ([Unit_Name =>] IDENTIFIER,
8253 [Unit_Symbol =>] SYMBOL,
8254 [Dim_Symbol =>] SYMBOL)
8255
8256 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
8257 @end smallexample
8258
8259 @noindent
8260 This aspect is applied to a type, which must be a numeric derived type
8261 (typically a floating-point type), that
8262 will represent values within the dimension system. Each @code{DIMENSION}
8263 corresponds to one particular dimension. A maximum of 7 dimensions may
8264 be specified. @code{Unit_Name} is the name of the dimension (for example
8265 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
8266 of this dimension (for example @code{m} for @code{Meter}).
8267 @code{Dim_Symbol} gives
8268 the identification within the dimension system (typically this is a
8269 single letter, e.g. @code{L} standing for length for unit name @code{Meter}).
8270 The @code{Unit_Symbol} is used in formatted output of dimensioned quantities.
8271 The @code{Dim_Symbol} is used in error messages when numeric operations have
8272 inconsistent dimensions.
8273
8274 GNAT provides the standard definition of the International MKS system in
8275 the run-time package @code{System.Dim.Mks}. You can easily define
8276 similar packages for cgs units or British units, and define conversion factors
8277 between values in different systems. The MKS system is characterized by the
8278 following aspect:
8279
8280 @smallexample @c ada
8281 type Mks_Type is new Long_Long_Float with
8282 Dimension_System => (
8283 (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
8284 (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
8285 (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
8286 (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
8287 (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => '@'),
8288 (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
8289 (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
8290 @end smallexample
8291
8292 @noindent
8293 Note that in the above type definition, we use the symbol @code{@@} to
8294 represent a theta character (avoiding the use of extended Latin-1
8295 characters in this context).
8296
8297 See section ``Performing Dimensionality Analysis in GNAT'' in the GNAT Users
8298 Guide for detailed examples of use of the dimension system.
8299
8300 @node Aspect Effective_Reads
8301 @unnumberedsec Aspect Effective_Reads
8302 @findex Effective_Reads
8303 @noindent
8304 This aspect is equivalent to pragma @code{Effective_Reads}.
8305
8306 @node Aspect Effective_Writes
8307 @unnumberedsec Aspect Effective_Writes
8308 @findex Effective_Writes
8309 @noindent
8310 This aspect is equivalent to pragma @code{Effective_Writes}.
8311
8312 @node Aspect Favor_Top_Level
8313 @unnumberedsec Aspect Favor_Top_Level
8314 @findex Favor_Top_Level
8315 @noindent
8316 This aspect is equivalent to pragma @code{Favor_Top_Level}.
8317
8318 @node Aspect Global
8319 @unnumberedsec Aspect Global
8320 @findex Global
8321 @noindent
8322 This aspect is equivalent to pragma @code{Global}.
8323
8324 @node Aspect Initial_Condition
8325 @unnumberedsec Aspect Initial_Condition
8326 @findex Initial_Condition
8327 @noindent
8328 This aspect is equivalent to pragma @code{Initial_Condition}.
8329
8330 @node Aspect Initializes
8331 @unnumberedsec Aspect Initializes
8332 @findex Initializes
8333 @noindent
8334 This aspect is equivalent to pragma @code{Initializes}.
8335
8336 @node Aspect Inline_Always
8337 @unnumberedsec Aspect Inline_Always
8338 @findex Inline_Always
8339 @noindent
8340 This aspect is equivalent to pragma @code{Inline_Always}.
8341
8342 @node Aspect Invariant
8343 @unnumberedsec Aspect Invariant
8344 @findex Invariant
8345 @noindent
8346 This aspect is equivalent to pragma @code{Invariant}. It is a
8347 synonym for the language defined aspect @code{Type_Invariant} except
8348 that it is separately controllable using pragma @code{Assertion_Policy}.
8349
8350 @node Aspect Iterable
8351 @unnumberedsec Aspect Iterable
8352 @findex Iterable
8353 @noindent
8354 This aspect is used in the GNAT-defined formal container packages, to provide
8355 a light-weight mechanism for loops over such containers, without the overhead
8356 imposed by the tampering checks of standard Ada2012 iterators. The value of the
8357 aspect is a aggregate with four named components: First, Next, Has_Element,
8358 and Element. The following is a typical example of use:
8359
8360 @smallexample @c ada
8361 type List is private with
8362 Iterable => (First => First_Element,
8363 Next => Advance,
8364 Has_Element => Get_Element,
8365 Element => List_Element);
8366 @end smallexample
8367 @itemize @bullet
8368 @item The value denoted by @code{First} must denote a primitive operation of
8369 the container type that returns a Cursor, which must a be a type declared in
8370 the container package.
8371 @item The value of @code{Next} is a primitive operation of the container type
8372 that takes a cursor and yields a cursor.
8373 @item @code{Has_Element} is an operation that applies to a cursor a yields an
8374 element of the container.
8375 @item @code{Element} is the type of the elements of the container type, and
8376 thus the result of the function denoted by Has_Element.
8377 @end itemize
8378
8379 @node Aspect Linker_Section
8380 @unnumberedsec Aspect Linker_Section
8381 @findex Linker_Section
8382 @noindent
8383 This aspect is equivalent to an @code{Linker_Section} pragma.
8384
8385 @node Aspect Lock_Free
8386 @unnumberedsec Aspect Lock_Free
8387 @findex Lock_Free
8388 @noindent
8389 This aspect is equivalent to pragma @code{Lock_Free}.
8390
8391 @node Aspect Object_Size
8392 @unnumberedsec Aspect Object_Size
8393 @findex Object_Size
8394 @noindent
8395 This aspect is equivalent to an @code{Object_Size} attribute definition
8396 clause.
8397
8398 @node Aspect Part_Of
8399 @unnumberedsec Aspect Part_Of
8400 @findex Part_Of
8401 @noindent
8402 This aspect is equivalent to pragma @code{Part_Of}.
8403
8404 @node Aspect Persistent_BSS
8405 @unnumberedsec Aspect Persistent_BSS
8406 @findex Persistent_BSS
8407 @noindent
8408 This aspect is equivalent to pragma @code{Persistent_BSS}.
8409
8410 @node Aspect Predicate
8411 @unnumberedsec Aspect Predicate
8412 @findex Predicate
8413 @noindent
8414 This aspect is equivalent to pragma @code{Predicate}. It is thus
8415 similar to the language defined aspects @code{Dynamic_Predicate}
8416 and @code{Static_Predicate} except that whether the resulting
8417 predicate is static or dynamic is controlled by the form of the
8418 expression. It is also separately controllable using pragma
8419 @code{Assertion_Policy}.
8420
8421 @node Aspect Pure_Function
8422 @unnumberedsec Aspect Pure_Function
8423 @findex Pure_Function
8424 @noindent
8425 This aspect is equivalent to pragma @code{Pure_Function}.
8426
8427 @node Aspect Refined_Depends
8428 @unnumberedsec Aspect Refined_Depends
8429 @findex Refined_Depends
8430 @noindent
8431 This aspect is equivalent to pragma @code{Refined_Depends}.
8432
8433 @node Aspect Refined_Global
8434 @unnumberedsec Aspect Refined_Global
8435 @findex Refined_Global
8436 @noindent
8437 This aspect is equivalent to pragma @code{Refined_Global}.
8438
8439 @node Aspect Refined_Post
8440 @unnumberedsec Aspect Refined_Post
8441 @findex Refined_Post
8442 @noindent
8443 This aspect is equivalent to pragma @code{Refined_Post}.
8444
8445 @node Aspect Refined_State
8446 @unnumberedsec Aspect Refined_State
8447 @findex Refined_State
8448 @noindent
8449 This aspect is equivalent to pragma @code{Refined_State}.
8450
8451 @node Aspect Remote_Access_Type
8452 @unnumberedsec Aspect Remote_Access_Type
8453 @findex Remote_Access_Type
8454 @noindent
8455 This aspect is equivalent to pragma @code{Remote_Access_Type}.
8456
8457 @node Aspect Scalar_Storage_Order
8458 @unnumberedsec Aspect Scalar_Storage_Order
8459 @findex Scalar_Storage_Order
8460 @noindent
8461 This aspect is equivalent to a @code{Scalar_Storage_Order}
8462 attribute definition clause.
8463
8464 @node Aspect Shared
8465 @unnumberedsec Aspect Shared
8466 @findex Shared
8467 @noindent
8468 This aspect is equivalent to pragma @code{Shared}, and is thus a synonym
8469 for aspect @code{Atomic}.
8470
8471 @node Aspect Simple_Storage_Pool
8472 @unnumberedsec Aspect Simple_Storage_Pool
8473 @findex Simple_Storage_Pool
8474 @noindent
8475 This aspect is equivalent to a @code{Simple_Storage_Pool}
8476 attribute definition clause.
8477
8478 @node Aspect Simple_Storage_Pool_Type
8479 @unnumberedsec Aspect Simple_Storage_Pool_Type
8480 @findex Simple_Storage_Pool_Type
8481 @noindent
8482 This aspect is equivalent to pragma @code{Simple_Storage_Pool_Type}.
8483
8484 @node Aspect SPARK_Mode
8485 @unnumberedsec Aspect SPARK_Mode
8486 @findex SPARK_Mode
8487 @noindent
8488 This aspect is equivalent to pragma @code{SPARK_Mode} and
8489 may be specified for either or both of the specification and body
8490 of a subprogram or package.
8491
8492 @node Aspect Suppress_Debug_Info
8493 @unnumberedsec Aspect Suppress_Debug_Info
8494 @findex Suppress_Debug_Info
8495 @noindent
8496 This aspect is equivalent to pragma @code{Suppress_Debug_Info}.
8497
8498 @node Aspect Test_Case
8499 @unnumberedsec Aspect Test_Case
8500 @findex Test_Case
8501 @noindent
8502 This aspect is equivalent to pragma @code{Test_Case}.
8503
8504 @node Aspect Thread_Local_Storage
8505 @unnumberedsec Aspect Thread_Local_Storage
8506 @findex Thread_Local_Storage
8507 @noindent
8508 This aspect is equivalent to pragma @code{Thread_Local_Storage}.
8509
8510 @node Aspect Universal_Aliasing
8511 @unnumberedsec Aspect Universal_Aliasing
8512 @findex Universal_Aliasing
8513 @noindent
8514 This aspect is equivalent to pragma @code{Universal_Aliasing}.
8515
8516 @node Aspect Universal_Data
8517 @unnumberedsec Aspect Universal_Data
8518 @findex Universal_Data
8519 @noindent
8520 This aspect is equivalent to pragma @code{Universal_Data}.
8521
8522 @node Aspect Unmodified
8523 @unnumberedsec Aspect Unmodified
8524 @findex Unmodified
8525 @noindent
8526 This aspect is equivalent to pragma @code{Unmodified}.
8527
8528 @node Aspect Unreferenced
8529 @unnumberedsec Aspect Unreferenced
8530 @findex Unreferenced
8531 @noindent
8532 This aspect is equivalent to pragma @code{Unreferenced}.
8533
8534 @node Aspect Unreferenced_Objects
8535 @unnumberedsec Aspect Unreferenced_Objects
8536 @findex Unreferenced_Objects
8537 @noindent
8538 This aspect is equivalent to pragma @code{Unreferenced_Objects}.
8539
8540 @node Aspect Value_Size
8541 @unnumberedsec Aspect Value_Size
8542 @findex Value_Size
8543 @noindent
8544 This aspect is equivalent to a @code{Value_Size}
8545 attribute definition clause.
8546
8547 @node Aspect Warnings
8548 @unnumberedsec Aspect Warnings
8549 @findex Warnings
8550 @noindent
8551 This aspect is equivalent to the two argument form of pragma @code{Warnings},
8552 where the first argument is @code{ON} or @code{OFF} and the second argument
8553 is the entity.
8554
8555
8556 @node Implementation Defined Attributes
8557 @chapter Implementation Defined Attributes
8558 Ada defines (throughout the Ada reference manual,
8559 summarized in Annex K),
8560 a set of attributes that provide useful additional functionality in all
8561 areas of the language. These language defined attributes are implemented
8562 in GNAT and work as described in the Ada Reference Manual.
8563
8564 In addition, Ada allows implementations to define additional
8565 attributes whose meaning is defined by the implementation. GNAT provides
8566 a number of these implementation-dependent attributes which can be used
8567 to extend and enhance the functionality of the compiler. This section of
8568 the GNAT reference manual describes these additional attributes. It also
8569 describes additional implementation-dependent features of standard
8570 language-defined attributes.
8571
8572 Note that any program using these attributes may not be portable to
8573 other compilers (although GNAT implements this set of attributes on all
8574 platforms). Therefore if portability to other compilers is an important
8575 consideration, you should minimize the use of these attributes.
8576
8577 @menu
8578 * Attribute Abort_Signal::
8579 * Attribute Address_Size::
8580 * Attribute Asm_Input::
8581 * Attribute Asm_Output::
8582 * Attribute AST_Entry::
8583 * Attribute Atomic_Always_Lock_Free::
8584 * Attribute Bit::
8585 * Attribute Bit_Position::
8586 * Attribute Code_Address::
8587 * Attribute Compiler_Version::
8588 * Attribute Constrained::
8589 * Attribute Default_Bit_Order::
8590 * Attribute Descriptor_Size::
8591 * Attribute Elaborated::
8592 * Attribute Elab_Body::
8593 * Attribute Elab_Spec::
8594 * Attribute Elab_Subp_Body::
8595 * Attribute Emax::
8596 * Attribute Enabled::
8597 * Attribute Enum_Rep::
8598 * Attribute Enum_Val::
8599 * Attribute Epsilon::
8600 * Attribute Fast_Math::
8601 * Attribute Fixed_Value::
8602 * Attribute From_Any::
8603 * Attribute Has_Access_Values::
8604 * Attribute Has_Discriminants::
8605 * Attribute Img::
8606 * Attribute Integer_Value::
8607 * Attribute Invalid_Value::
8608 * Attribute Iterable::
8609 * Attribute Large::
8610 * Attribute Library_Level::
8611 * Attribute Lock_Free::
8612 * Attribute Loop_Entry::
8613 * Attribute Machine_Size::
8614 * Attribute Mantissa::
8615 * Attribute Maximum_Alignment::
8616 * Attribute Mechanism_Code::
8617 * Attribute Null_Parameter::
8618 * Attribute Object_Size::
8619 * Attribute Old::
8620 * Attribute Passed_By_Reference::
8621 * Attribute Pool_Address::
8622 * Attribute Range_Length::
8623 * Attribute Ref::
8624 * Attribute Restriction_Set::
8625 * Attribute Result::
8626 * Attribute Safe_Emax::
8627 * Attribute Safe_Large::
8628 * Attribute Safe_Small::
8629 * Attribute Scalar_Storage_Order::
8630 * Attribute Simple_Storage_Pool::
8631 * Attribute Small::
8632 * Attribute Storage_Unit::
8633 * Attribute Stub_Type::
8634 * Attribute System_Allocator_Alignment::
8635 * Attribute Target_Name::
8636 * Attribute To_Address::
8637 * Attribute To_Any::
8638 * Attribute Type_Class::
8639 * Attribute Type_Key::
8640 * Attribute TypeCode::
8641 * Attribute UET_Address::
8642 * Attribute Unconstrained_Array::
8643 * Attribute Universal_Literal_String::
8644 * Attribute Unrestricted_Access::
8645 * Attribute Update::
8646 * Attribute VADS_Size::
8647 * Attribute Valid_Scalars::
8648 * Attribute Value_Size::
8649 * Attribute Wchar_T_Size::
8650 * Attribute Word_Size::
8651 @end menu
8652
8653 @node Attribute Abort_Signal
8654 @unnumberedsec Attribute Abort_Signal
8655 @findex Abort_Signal
8656 @noindent
8657 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
8658 prefix) provides the entity for the special exception used to signal
8659 task abort or asynchronous transfer of control. Normally this attribute
8660 should only be used in the tasking runtime (it is highly peculiar, and
8661 completely outside the normal semantics of Ada, for a user program to
8662 intercept the abort exception).
8663
8664 @node Attribute Address_Size
8665 @unnumberedsec Attribute Address_Size
8666 @cindex Size of @code{Address}
8667 @findex Address_Size
8668 @noindent
8669 @code{Standard'Address_Size} (@code{Standard} is the only allowed
8670 prefix) is a static constant giving the number of bits in an
8671 @code{Address}. It is the same value as System.Address'Size,
8672 but has the advantage of being static, while a direct
8673 reference to System.Address'Size is non-static because Address
8674 is a private type.
8675
8676 @node Attribute Asm_Input
8677 @unnumberedsec Attribute Asm_Input
8678 @findex Asm_Input
8679 @noindent
8680 The @code{Asm_Input} attribute denotes a function that takes two
8681 parameters. The first is a string, the second is an expression of the
8682 type designated by the prefix. The first (string) argument is required
8683 to be a static expression, and is the constraint for the parameter,
8684 (e.g.@: what kind of register is required). The second argument is the
8685 value to be used as the input argument. The possible values for the
8686 constant are the same as those used in the RTL, and are dependent on
8687 the configuration file used to built the GCC back end.
8688 @ref{Machine Code Insertions}
8689
8690 @node Attribute Asm_Output
8691 @unnumberedsec Attribute Asm_Output
8692 @findex Asm_Output
8693 @noindent
8694 The @code{Asm_Output} attribute denotes a function that takes two
8695 parameters. The first is a string, the second is the name of a variable
8696 of the type designated by the attribute prefix. The first (string)
8697 argument is required to be a static expression and designates the
8698 constraint for the parameter (e.g.@: what kind of register is
8699 required). The second argument is the variable to be updated with the
8700 result. The possible values for constraint are the same as those used in
8701 the RTL, and are dependent on the configuration file used to build the
8702 GCC back end. If there are no output operands, then this argument may
8703 either be omitted, or explicitly given as @code{No_Output_Operands}.
8704 @ref{Machine Code Insertions}
8705
8706 @node Attribute AST_Entry
8707 @unnumberedsec Attribute AST_Entry
8708 @cindex OpenVMS
8709 @findex AST_Entry
8710 @noindent
8711 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
8712 the name of an entry, it yields a value of the predefined type AST_Handler
8713 (declared in the predefined package System, as extended by the use of
8714 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
8715 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
8716 Language Reference Manual}, section 9.12a.
8717
8718 @node Attribute Atomic_Always_Lock_Free
8719 @unnumberedsec Attribute Atomic_Always_Lock_Free
8720 @findex Atomic_Always_Lock_Free
8721 @noindent
8722
8723 The prefix of the @code{Atomic_Always_Lock_Free} attribute is a type.
8724 The result is a Boolean value which is True if the type has discriminants,
8725 and False otherwise. The result indicate whether atomic operations are
8726 supported by the target for the given type.
8727
8728 @node Attribute Bit
8729 @unnumberedsec Attribute Bit
8730 @findex Bit
8731 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
8732 offset within the storage unit (byte) that contains the first bit of
8733 storage allocated for the object. The value of this attribute is of the
8734 type @code{Universal_Integer}, and is always a non-negative number not
8735 exceeding the value of @code{System.Storage_Unit}.
8736
8737 For an object that is a variable or a constant allocated in a register,
8738 the value is zero. (The use of this attribute does not force the
8739 allocation of a variable to memory).
8740
8741 For an object that is a formal parameter, this attribute applies
8742 to either the matching actual parameter or to a copy of the
8743 matching actual parameter.
8744
8745 For an access object the value is zero. Note that
8746 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
8747 designated object. Similarly for a record component
8748 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
8749 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
8750 are subject to index checks.
8751
8752 This attribute is designed to be compatible with the DEC Ada 83 definition
8753 and implementation of the @code{Bit} attribute.
8754
8755 @node Attribute Bit_Position
8756 @unnumberedsec Attribute Bit_Position
8757 @findex Bit_Position
8758 @noindent
8759 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
8760 of the fields of the record type, yields the bit
8761 offset within the record contains the first bit of
8762 storage allocated for the object. The value of this attribute is of the
8763 type @code{Universal_Integer}. The value depends only on the field
8764 @var{C} and is independent of the alignment of
8765 the containing record @var{R}.
8766
8767 @node Attribute Code_Address
8768 @unnumberedsec Attribute Code_Address
8769 @findex Code_Address
8770 @cindex Subprogram address
8771 @cindex Address of subprogram code
8772 @noindent
8773 The @code{'Address}
8774 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
8775 intended effect seems to be to provide
8776 an address value which can be used to call the subprogram by means of
8777 an address clause as in the following example:
8778
8779 @smallexample @c ada
8780 procedure K is @dots{}
8781
8782 procedure L;
8783 for L'Address use K'Address;
8784 pragma Import (Ada, L);
8785 @end smallexample
8786
8787 @noindent
8788 A call to @code{L} is then expected to result in a call to @code{K}@.
8789 In Ada 83, where there were no access-to-subprogram values, this was
8790 a common work-around for getting the effect of an indirect call.
8791 GNAT implements the above use of @code{Address} and the technique
8792 illustrated by the example code works correctly.
8793
8794 However, for some purposes, it is useful to have the address of the start
8795 of the generated code for the subprogram. On some architectures, this is
8796 not necessarily the same as the @code{Address} value described above.
8797 For example, the @code{Address} value may reference a subprogram
8798 descriptor rather than the subprogram itself.
8799
8800 The @code{'Code_Address} attribute, which can only be applied to
8801 subprogram entities, always returns the address of the start of the
8802 generated code of the specified subprogram, which may or may not be
8803 the same value as is returned by the corresponding @code{'Address}
8804 attribute.
8805
8806 @node Attribute Compiler_Version
8807 @unnumberedsec Attribute Compiler_Version
8808 @findex Compiler_Version
8809 @noindent
8810 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
8811 prefix) yields a static string identifying the version of the compiler
8812 being used to compile the unit containing the attribute reference. A
8813 typical result would be something like
8814 "@value{EDITION} @value{gnat_version} (20090221)".
8815
8816 @node Attribute Constrained
8817 @unnumberedsec Attribute Constrained
8818 @findex Constrained
8819 @noindent
8820 In addition to the usage of this attribute in the Ada RM, @code{GNAT}
8821 also permits the use of the @code{'Constrained} attribute
8822 in a generic template
8823 for any type, including types without discriminants. The value of this
8824 attribute in the generic instance when applied to a scalar type or a
8825 record type without discriminants is always @code{True}. This usage is
8826 compatible with older Ada compilers, including notably DEC Ada.
8827
8828 @node Attribute Default_Bit_Order
8829 @unnumberedsec Attribute Default_Bit_Order
8830 @cindex Big endian
8831 @cindex Little endian
8832 @findex Default_Bit_Order
8833 @noindent
8834 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
8835 permissible prefix), provides the value @code{System.Default_Bit_Order}
8836 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
8837 @code{Low_Order_First}). This is used to construct the definition of
8838 @code{Default_Bit_Order} in package @code{System}.
8839
8840 @node Attribute Descriptor_Size
8841 @unnumberedsec Attribute Descriptor_Size
8842 @cindex Descriptor
8843 @cindex Dope vector
8844 @findex Descriptor_Size
8845 @noindent
8846 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
8847 descriptor allocated for a type. The result is non-zero only for unconstrained
8848 array types and the returned value is of type universal integer. In GNAT, an
8849 array descriptor contains bounds information and is located immediately before
8850 the first element of the array.
8851
8852 @smallexample @c ada
8853 type Unconstr_Array is array (Positive range <>) of Boolean;
8854 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
8855 @end smallexample
8856
8857 @noindent
8858 The attribute takes into account any additional padding due to type alignment.
8859 In the example above, the descriptor contains two values of type
8860 @code{Positive} representing the low and high bound. Since @code{Positive} has
8861 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
8862 Positive'Size + 2} or 64 bits.
8863
8864 @node Attribute Elaborated
8865 @unnumberedsec Attribute Elaborated
8866 @findex Elaborated
8867 @noindent
8868 The prefix of the @code{'Elaborated} attribute must be a unit name. The
8869 value is a Boolean which indicates whether or not the given unit has been
8870 elaborated. This attribute is primarily intended for internal use by the
8871 generated code for dynamic elaboration checking, but it can also be used
8872 in user programs. The value will always be True once elaboration of all
8873 units has been completed. An exception is for units which need no
8874 elaboration, the value is always False for such units.
8875
8876 @node Attribute Elab_Body
8877 @unnumberedsec Attribute Elab_Body
8878 @findex Elab_Body
8879 @noindent
8880 This attribute can only be applied to a program unit name. It returns
8881 the entity for the corresponding elaboration procedure for elaborating
8882 the body of the referenced unit. This is used in the main generated
8883 elaboration procedure by the binder and is not normally used in any
8884 other context. However, there may be specialized situations in which it
8885 is useful to be able to call this elaboration procedure from Ada code,
8886 e.g.@: if it is necessary to do selective re-elaboration to fix some
8887 error.
8888
8889 @node Attribute Elab_Spec
8890 @unnumberedsec Attribute Elab_Spec
8891 @findex Elab_Spec
8892 @noindent
8893 This attribute can only be applied to a program unit name. It returns
8894 the entity for the corresponding elaboration procedure for elaborating
8895 the spec of the referenced unit. This is used in the main
8896 generated elaboration procedure by the binder and is not normally used
8897 in any other context. However, there may be specialized situations in
8898 which it is useful to be able to call this elaboration procedure from
8899 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
8900 some error.
8901
8902 @node Attribute Elab_Subp_Body
8903 @unnumberedsec Attribute Elab_Subp_Body
8904 @findex Elab_Subp_Body
8905 @noindent
8906 This attribute can only be applied to a library level subprogram
8907 name and is only allowed in CodePeer mode. It returns the entity
8908 for the corresponding elaboration procedure for elaborating the body
8909 of the referenced subprogram unit. This is used in the main generated
8910 elaboration procedure by the binder in CodePeer mode only and is unrecognized
8911 otherwise.
8912
8913 @node Attribute Emax
8914 @unnumberedsec Attribute Emax
8915 @cindex Ada 83 attributes
8916 @findex Emax
8917 @noindent
8918 The @code{Emax} attribute is provided for compatibility with Ada 83. See
8919 the Ada 83 reference manual for an exact description of the semantics of
8920 this attribute.
8921
8922 @node Attribute Enabled
8923 @unnumberedsec Attribute Enabled
8924 @findex Enabled
8925 @noindent
8926 The @code{Enabled} attribute allows an application program to check at compile
8927 time to see if the designated check is currently enabled. The prefix is a
8928 simple identifier, referencing any predefined check name (other than
8929 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
8930 no argument is given for the attribute, the check is for the general state
8931 of the check, if an argument is given, then it is an entity name, and the
8932 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
8933 given naming the entity (if not, then the argument is ignored).
8934
8935 Note that instantiations inherit the check status at the point of the
8936 instantiation, so a useful idiom is to have a library package that
8937 introduces a check name with @code{pragma Check_Name}, and then contains
8938 generic packages or subprograms which use the @code{Enabled} attribute
8939 to see if the check is enabled. A user of this package can then issue
8940 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
8941 the package or subprogram, controlling whether the check will be present.
8942
8943 @node Attribute Enum_Rep
8944 @unnumberedsec Attribute Enum_Rep
8945 @cindex Representation of enums
8946 @findex Enum_Rep
8947 @noindent
8948 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
8949 function with the following spec:
8950
8951 @smallexample @c ada
8952 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
8953 return @i{Universal_Integer};
8954 @end smallexample
8955
8956 @noindent
8957 It is also allowable to apply @code{Enum_Rep} directly to an object of an
8958 enumeration type or to a non-overloaded enumeration
8959 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
8960 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
8961 enumeration literal or object.
8962
8963 The function returns the representation value for the given enumeration
8964 value. This will be equal to value of the @code{Pos} attribute in the
8965 absence of an enumeration representation clause. This is a static
8966 attribute (i.e.@: the result is static if the argument is static).
8967
8968 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
8969 in which case it simply returns the integer value. The reason for this
8970 is to allow it to be used for @code{(<>)} discrete formal arguments in
8971 a generic unit that can be instantiated with either enumeration types
8972 or integer types. Note that if @code{Enum_Rep} is used on a modular
8973 type whose upper bound exceeds the upper bound of the largest signed
8974 integer type, and the argument is a variable, so that the universal
8975 integer calculation is done at run time, then the call to @code{Enum_Rep}
8976 may raise @code{Constraint_Error}.
8977
8978 @node Attribute Enum_Val
8979 @unnumberedsec Attribute Enum_Val
8980 @cindex Representation of enums
8981 @findex Enum_Val
8982 @noindent
8983 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
8984 function with the following spec:
8985
8986 @smallexample @c ada
8987 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
8988 return @var{S}'Base};
8989 @end smallexample
8990
8991 @noindent
8992 The function returns the enumeration value whose representation matches the
8993 argument, or raises Constraint_Error if no enumeration literal of the type
8994 has the matching value.
8995 This will be equal to value of the @code{Val} attribute in the
8996 absence of an enumeration representation clause. This is a static
8997 attribute (i.e.@: the result is static if the argument is static).
8998
8999 @node Attribute Epsilon
9000 @unnumberedsec Attribute Epsilon
9001 @cindex Ada 83 attributes
9002 @findex Epsilon
9003 @noindent
9004 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
9005 the Ada 83 reference manual for an exact description of the semantics of
9006 this attribute.
9007
9008 @node Attribute Fast_Math
9009 @unnumberedsec Attribute Fast_Math
9010 @findex Fast_Math
9011 @noindent
9012 @code{Standard'Fast_Math} (@code{Standard} is the only allowed
9013 prefix) yields a static Boolean value that is True if pragma
9014 @code{Fast_Math} is active, and False otherwise.
9015
9016 @node Attribute Fixed_Value
9017 @unnumberedsec Attribute Fixed_Value
9018 @findex Fixed_Value
9019 @noindent
9020 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
9021 function with the following specification:
9022
9023 @smallexample @c ada
9024 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
9025 return @var{S};
9026 @end smallexample
9027
9028 @noindent
9029 The value returned is the fixed-point value @var{V} such that
9030
9031 @smallexample @c ada
9032 @var{V} = Arg * @var{S}'Small
9033 @end smallexample
9034
9035 @noindent
9036 The effect is thus similar to first converting the argument to the
9037 integer type used to represent @var{S}, and then doing an unchecked
9038 conversion to the fixed-point type. The difference is
9039 that there are full range checks, to ensure that the result is in range.
9040 This attribute is primarily intended for use in implementation of the
9041 input-output functions for fixed-point values.
9042
9043 @node Attribute From_Any
9044 @unnumberedsec Attribute From_Any
9045 @findex From_Any
9046 @noindent
9047 This internal attribute is used for the generation of remote subprogram
9048 stubs in the context of the Distributed Systems Annex.
9049
9050 @node Attribute Has_Access_Values
9051 @unnumberedsec Attribute Has_Access_Values
9052 @cindex Access values, testing for
9053 @findex Has_Access_Values
9054 @noindent
9055 The prefix of the @code{Has_Access_Values} attribute is a type. The result
9056 is a Boolean value which is True if the is an access type, or is a composite
9057 type with a component (at any nesting depth) that is an access type, and is
9058 False otherwise.
9059 The intended use of this attribute is in conjunction with generic
9060 definitions. If the attribute is applied to a generic private type, it
9061 indicates whether or not the corresponding actual type has access values.
9062
9063 @node Attribute Has_Discriminants
9064 @unnumberedsec Attribute Has_Discriminants
9065 @cindex Discriminants, testing for
9066 @findex Has_Discriminants
9067 @noindent
9068 The prefix of the @code{Has_Discriminants} attribute is a type. The result
9069 is a Boolean value which is True if the type has discriminants, and False
9070 otherwise. The intended use of this attribute is in conjunction with generic
9071 definitions. If the attribute is applied to a generic private type, it
9072 indicates whether or not the corresponding actual type has discriminants.
9073
9074 @node Attribute Img
9075 @unnumberedsec Attribute Img
9076 @findex Img
9077 @noindent
9078 The @code{Img} attribute differs from @code{Image} in that it is applied
9079 directly to an object, and yields the same result as
9080 @code{Image} for the subtype of the object. This is convenient for
9081 debugging:
9082
9083 @smallexample @c ada
9084 Put_Line ("X = " & X'Img);
9085 @end smallexample
9086
9087 @noindent
9088 has the same meaning as the more verbose:
9089
9090 @smallexample @c ada
9091 Put_Line ("X = " & @var{T}'Image (X));
9092 @end smallexample
9093
9094 @noindent
9095 where @var{T} is the (sub)type of the object @code{X}.
9096
9097 Note that technically, in analogy to @code{Image},
9098 @code{X'Img} returns a parameterless function
9099 that returns the appropriate string when called. This means that
9100 @code{X'Img} can be renamed as a function-returning-string, or used
9101 in an instantiation as a function parameter.
9102
9103 @node Attribute Integer_Value
9104 @unnumberedsec Attribute Integer_Value
9105 @findex Integer_Value
9106 @noindent
9107 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
9108 function with the following spec:
9109
9110 @smallexample @c ada
9111 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
9112 return @var{S};
9113 @end smallexample
9114
9115 @noindent
9116 The value returned is the integer value @var{V}, such that
9117
9118 @smallexample @c ada
9119 Arg = @var{V} * @var{T}'Small
9120 @end smallexample
9121
9122 @noindent
9123 where @var{T} is the type of @code{Arg}.
9124 The effect is thus similar to first doing an unchecked conversion from
9125 the fixed-point type to its corresponding implementation type, and then
9126 converting the result to the target integer type. The difference is
9127 that there are full range checks, to ensure that the result is in range.
9128 This attribute is primarily intended for use in implementation of the
9129 standard input-output functions for fixed-point values.
9130
9131 @node Attribute Invalid_Value
9132 @unnumberedsec Attribute Invalid_Value
9133 @findex Invalid_Value
9134 @noindent
9135 For every scalar type S, S'Invalid_Value returns an undefined value of the
9136 type. If possible this value is an invalid representation for the type. The
9137 value returned is identical to the value used to initialize an otherwise
9138 uninitialized value of the type if pragma Initialize_Scalars is used,
9139 including the ability to modify the value with the binder -Sxx flag and
9140 relevant environment variables at run time.
9141
9142 @node Attribute Iterable
9143 @unnumberedsec Attribute Iterable
9144 @findex Iterable
9145 @noindent
9146 Equivalent to Aspect Iterable.
9147
9148 @node Attribute Large
9149 @unnumberedsec Attribute Large
9150 @cindex Ada 83 attributes
9151 @findex Large
9152 @noindent
9153 The @code{Large} attribute is provided for compatibility with Ada 83. See
9154 the Ada 83 reference manual for an exact description of the semantics of
9155 this attribute.
9156
9157 @node Attribute Library_Level
9158 @unnumberedsec Attribute Library_Level
9159 @findex Library_Level
9160 @noindent
9161 @noindent
9162 @code{P'Library_Level}, where P is an entity name,
9163 returns a Boolean value which is True if the entity is declared
9164 at the library level, and False otherwise. Note that within a
9165 generic instantition, the name of the generic unit denotes the
9166 instance, which means that this attribute can be used to test
9167 if a generic is instantiated at the library level, as shown
9168 in this example:
9169
9170 @smallexample @c ada
9171 generic
9172 ...
9173 package Gen is
9174 pragma Compile_Time_Error
9175 (not Gen'Library_Level,
9176 "Gen can only be instantiated at library level");
9177 ...
9178 end Gen;
9179 @end smallexample
9180
9181 @node Attribute Lock_Free
9182 @unnumberedsec Attribute Lock_Free
9183 @findex Lock_Free
9184 @noindent
9185 @code{P'Lock_Free}, where P is a protected object, returns True if a
9186 pragma @code{Lock_Free} applies to P.
9187
9188 @node Attribute Loop_Entry
9189 @unnumberedsec Attribute Loop_Entry
9190 @findex Loop_Entry
9191 @noindent
9192 Syntax:
9193
9194 @smallexample @c ada
9195 X'Loop_Entry [(loop_name)]
9196 @end smallexample
9197
9198 @noindent
9199 The @code{Loop_Entry} attribute is used to refer to the value that an
9200 expression had upon entry to a given loop in much the same way that the
9201 @code{Old} attribute in a subprogram postcondition can be used to refer
9202 to the value an expression had upon entry to the subprogram. The
9203 relevant loop is either identified by the given loop name, or it is the
9204 innermost enclosing loop when no loop name is given.
9205
9206 @noindent
9207 A @code{Loop_Entry} attribute can only occur within a
9208 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
9209 @code{Loop_Entry} is to compare the current value of objects with their
9210 initial value at loop entry, in a @code{Loop_Invariant} pragma.
9211
9212 @noindent
9213 The effect of using @code{X'Loop_Entry} is the same as declaring
9214 a constant initialized with the initial value of @code{X} at loop
9215 entry. This copy is not performed if the loop is not entered, or if the
9216 corresponding pragmas are ignored or disabled.
9217
9218 @node Attribute Machine_Size
9219 @unnumberedsec Attribute Machine_Size
9220 @findex Machine_Size
9221 @noindent
9222 This attribute is identical to the @code{Object_Size} attribute. It is
9223 provided for compatibility with the DEC Ada 83 attribute of this name.
9224
9225 @node Attribute Mantissa
9226 @unnumberedsec Attribute Mantissa
9227 @cindex Ada 83 attributes
9228 @findex Mantissa
9229 @noindent
9230 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
9231 the Ada 83 reference manual for an exact description of the semantics of
9232 this attribute.
9233
9234 @node Attribute Maximum_Alignment
9235 @unnumberedsec Attribute Maximum_Alignment
9236 @cindex Alignment, maximum
9237 @findex Maximum_Alignment
9238 @noindent
9239 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
9240 permissible prefix) provides the maximum useful alignment value for the
9241 target. This is a static value that can be used to specify the alignment
9242 for an object, guaranteeing that it is properly aligned in all
9243 cases.
9244
9245 @node Attribute Mechanism_Code
9246 @unnumberedsec Attribute Mechanism_Code
9247 @cindex Return values, passing mechanism
9248 @cindex Parameters, passing mechanism
9249 @findex Mechanism_Code
9250 @noindent
9251 @code{@var{function}'Mechanism_Code} yields an integer code for the
9252 mechanism used for the result of function, and
9253 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
9254 used for formal parameter number @var{n} (a static integer value with 1
9255 meaning the first parameter) of @var{subprogram}. The code returned is:
9256
9257 @table @asis
9258 @item 1
9259 by copy (value)
9260 @item 2
9261 by reference
9262 @item 3
9263 by descriptor (default descriptor class)
9264 @item 4
9265 by descriptor (UBS: unaligned bit string)
9266 @item 5
9267 by descriptor (UBSB: aligned bit string with arbitrary bounds)
9268 @item 6
9269 by descriptor (UBA: unaligned bit array)
9270 @item 7
9271 by descriptor (S: string, also scalar access type parameter)
9272 @item 8
9273 by descriptor (SB: string with arbitrary bounds)
9274 @item 9
9275 by descriptor (A: contiguous array)
9276 @item 10
9277 by descriptor (NCA: non-contiguous array)
9278 @end table
9279
9280 @noindent
9281 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
9282 @cindex OpenVMS
9283
9284 @node Attribute Null_Parameter
9285 @unnumberedsec Attribute Null_Parameter
9286 @cindex Zero address, passing
9287 @findex Null_Parameter
9288 @noindent
9289 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
9290 type or subtype @var{T} allocated at machine address zero. The attribute
9291 is allowed only as the default expression of a formal parameter, or as
9292 an actual expression of a subprogram call. In either case, the
9293 subprogram must be imported.
9294
9295 The identity of the object is represented by the address zero in the
9296 argument list, independent of the passing mechanism (explicit or
9297 default).
9298
9299 This capability is needed to specify that a zero address should be
9300 passed for a record or other composite object passed by reference.
9301 There is no way of indicating this without the @code{Null_Parameter}
9302 attribute.
9303
9304 @node Attribute Object_Size
9305 @unnumberedsec Attribute Object_Size
9306 @cindex Size, used for objects
9307 @findex Object_Size
9308 @noindent
9309 The size of an object is not necessarily the same as the size of the type
9310 of an object. This is because by default object sizes are increased to be
9311 a multiple of the alignment of the object. For example,
9312 @code{Natural'Size} is
9313 31, but by default objects of type @code{Natural} will have a size of 32 bits.
9314 Similarly, a record containing an integer and a character:
9315
9316 @smallexample @c ada
9317 type Rec is record
9318 I : Integer;
9319 C : Character;
9320 end record;
9321 @end smallexample
9322
9323 @noindent
9324 will have a size of 40 (that is @code{Rec'Size} will be 40). The
9325 alignment will be 4, because of the
9326 integer field, and so the default size of record objects for this type
9327 will be 64 (8 bytes).
9328
9329 If the alignment of the above record is specified to be 1, then the
9330 object size will be 40 (5 bytes). This is true by default, and also
9331 an object size of 40 can be explicitly specified in this case.
9332
9333 A consequence of this capability is that different object sizes can be
9334 given to subtypes that would otherwise be considered in Ada to be
9335 statically matching. But it makes no sense to consider such subtypes
9336 as statically matching. Consequently, in @code{GNAT} we add a rule
9337 to the static matching rules that requires object sizes to match.
9338 Consider this example:
9339
9340 @smallexample @c ada
9341 1. procedure BadAVConvert is
9342 2. type R is new Integer;
9343 3. subtype R1 is R range 1 .. 10;
9344 4. subtype R2 is R range 1 .. 10;
9345 5. for R1'Object_Size use 8;
9346 6. for R2'Object_Size use 16;
9347 7. type R1P is access all R1;
9348 8. type R2P is access all R2;
9349 9. R1PV : R1P := new R1'(4);
9350 10. R2PV : R2P;
9351 11. begin
9352 12. R2PV := R2P (R1PV);
9353 |
9354 >>> target designated subtype not compatible with
9355 type "R1" defined at line 3
9356
9357 13. end;
9358 @end smallexample
9359
9360 @noindent
9361 In the absence of lines 5 and 6,
9362 types @code{R1} and @code{R2} statically match and
9363 hence the conversion on line 12 is legal. But since lines 5 and 6
9364 cause the object sizes to differ, @code{GNAT} considers that types
9365 @code{R1} and @code{R2} are not statically matching, and line 12
9366 generates the diagnostic shown above.
9367
9368 @noindent
9369 Similar additional checks are performed in other contexts requiring
9370 statically matching subtypes.
9371
9372 @node Attribute Old
9373 @unnumberedsec Attribute Old
9374 @findex Old
9375 @noindent
9376 In addition to the usage of @code{Old} defined in the Ada 2012 RM (usage
9377 within @code{Post} aspect), GNAT also permits the use of this attribute
9378 in implementation defined pragmas @code{Postcondition},
9379 @code{Contract_Cases} and @code{Test_Case}. Also usages of
9380 @code{Old} which would be illegal according to the Ada 2012 RM
9381 definition are allowed under control of
9382 implementation defined pragma @code{Unevaluated_Use_Of_Old}.
9383
9384 @node Attribute Passed_By_Reference
9385 @unnumberedsec Attribute Passed_By_Reference
9386 @cindex Parameters, when passed by reference
9387 @findex Passed_By_Reference
9388 @noindent
9389 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
9390 a value of type @code{Boolean} value that is @code{True} if the type is
9391 normally passed by reference and @code{False} if the type is normally
9392 passed by copy in calls. For scalar types, the result is always @code{False}
9393 and is static. For non-scalar types, the result is non-static.
9394
9395 @node Attribute Pool_Address
9396 @unnumberedsec Attribute Pool_Address
9397 @cindex Parameters, when passed by reference
9398 @findex Pool_Address
9399 @noindent
9400 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
9401 of X within its storage pool. This is the same as
9402 @code{@var{X}'Address}, except that for an unconstrained array whose
9403 bounds are allocated just before the first component,
9404 @code{@var{X}'Pool_Address} returns the address of those bounds,
9405 whereas @code{@var{X}'Address} returns the address of the first
9406 component.
9407
9408 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
9409 the object is allocated'', which could be a user-defined storage pool,
9410 the global heap, on the stack, or in a static memory area. For an
9411 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
9412 what is passed to @code{Allocate} and returned from @code{Deallocate}.
9413
9414 @node Attribute Range_Length
9415 @unnumberedsec Attribute Range_Length
9416 @findex Range_Length
9417 @noindent
9418 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
9419 the number of values represented by the subtype (zero for a null
9420 range). The result is static for static subtypes. @code{Range_Length}
9421 applied to the index subtype of a one dimensional array always gives the
9422 same result as @code{Length} applied to the array itself.
9423
9424 @node Attribute Ref
9425 @unnumberedsec Attribute Ref
9426 @findex Ref
9427 @noindent
9428
9429
9430 @node Attribute Restriction_Set
9431 @unnumberedsec Attribute Restriction_Set
9432 @findex Restriction_Set
9433 @cindex Restrictions
9434 @noindent
9435 This attribute allows compile time testing of restrictions that
9436 are currently in effect. It is primarily intended for specializing
9437 code in the run-time based on restrictions that are active (e.g.
9438 don't need to save fpt registers if restriction No_Floating_Point
9439 is known to be in effect), but can be used anywhere.
9440
9441 There are two forms:
9442
9443 @smallexample @c ada
9444 System'Restriction_Set (partition_boolean_restriction_NAME)
9445 System'Restriction_Set (No_Dependence => library_unit_NAME);
9446 @end smallexample
9447
9448 @noindent
9449 In the case of the first form, the only restriction names
9450 allowed are parameterless restrictions that are checked
9451 for consistency at bind time. For a complete list see the
9452 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
9453
9454 The result returned is True if the restriction is known to
9455 be in effect, and False if the restriction is known not to
9456 be in effect. An important guarantee is that the value of
9457 a Restriction_Set attribute is known to be consistent throughout
9458 all the code of a partition.
9459
9460 This is trivially achieved if the entire partition is compiled
9461 with a consistent set of restriction pragmas. However, the
9462 compilation model does not require this. It is possible to
9463 compile one set of units with one set of pragmas, and another
9464 set of units with another set of pragmas. It is even possible
9465 to compile a spec with one set of pragmas, and then WITH the
9466 same spec with a different set of pragmas. Inconsistencies
9467 in the actual use of the restriction are checked at bind time.
9468
9469 In order to achieve the guarantee of consistency for the
9470 Restriction_Set pragma, we consider that a use of the pragma
9471 that yields False is equivalent to a violation of the
9472 restriction.
9473
9474 So for example if you write
9475
9476 @smallexample @c ada
9477 if System'Restriction_Set (No_Floating_Point) then
9478 ...
9479 else
9480 ...
9481 end if;
9482 @end smallexample
9483
9484 @noindent
9485 And the result is False, so that the else branch is executed,
9486 you can assume that this restriction is not set for any unit
9487 in the partition. This is checked by considering this use of
9488 the restriction pragma to be a violation of the restriction
9489 No_Floating_Point. This means that no other unit can attempt
9490 to set this restriction (if some unit does attempt to set it,
9491 the binder will refuse to bind the partition).
9492
9493 Technical note: The restriction name and the unit name are
9494 intepreted entirely syntactically, as in the corresponding
9495 Restrictions pragma, they are not analyzed semantically,
9496 so they do not have a type.
9497
9498 @node Attribute Result
9499 @unnumberedsec Attribute Result
9500 @findex Result
9501 @noindent
9502 @code{@var{function}'Result} can only be used with in a Postcondition pragma
9503 for a function. The prefix must be the name of the corresponding function. This
9504 is used to refer to the result of the function in the postcondition expression.
9505 For a further discussion of the use of this attribute and examples of its use,
9506 see the description of pragma Postcondition.
9507
9508 @node Attribute Safe_Emax
9509 @unnumberedsec Attribute Safe_Emax
9510 @cindex Ada 83 attributes
9511 @findex Safe_Emax
9512 @noindent
9513 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
9514 the Ada 83 reference manual for an exact description of the semantics of
9515 this attribute.
9516
9517 @node Attribute Safe_Large
9518 @unnumberedsec Attribute Safe_Large
9519 @cindex Ada 83 attributes
9520 @findex Safe_Large
9521 @noindent
9522 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
9523 the Ada 83 reference manual for an exact description of the semantics of
9524 this attribute.
9525
9526 @node Attribute Safe_Small
9527 @unnumberedsec Attribute Safe_Small
9528 @cindex Ada 83 attributes
9529 @findex Safe_Small
9530 @noindent
9531 The @code{Safe_Small} attribute is provided for compatibility with Ada 83. See
9532 the Ada 83 reference manual for an exact description of the semantics of
9533 this attribute.
9534
9535 @node Attribute Scalar_Storage_Order
9536 @unnumberedsec Attribute Scalar_Storage_Order
9537 @cindex Endianness
9538 @cindex Scalar storage order
9539 @findex Scalar_Storage_Order
9540 @noindent
9541 For every array or record type @var{S}, the representation attribute
9542 @code{Scalar_Storage_Order} denotes the order in which storage elements
9543 that make up scalar components are ordered within S. The value given must
9544 be a static expression of type System.Bit_Order. The following is an example
9545 of the use of this feature:
9546
9547 @smallexample @c ada
9548 -- Component type definitions
9549
9550 subtype Yr_Type is Natural range 0 .. 127;
9551 subtype Mo_Type is Natural range 1 .. 12;
9552 subtype Da_Type is Natural range 1 .. 31;
9553
9554 -- Record declaration
9555
9556 type Date is record
9557 Years_Since_1980 : Yr_Type;
9558 Month : Mo_Type;
9559 Day_Of_Month : Da_Type;
9560 end record;
9561
9562 -- Record representation clause
9563
9564 for Date use record
9565 Years_Since_1980 at 0 range 0 .. 6;
9566 Month at 0 range 7 .. 10;
9567 Day_Of_Month at 0 range 11 .. 15;
9568 end record;
9569
9570 -- Attribute definition clauses
9571
9572 for Date'Bit_Order use System.High_Order_First;
9573 for Date'Scalar_Storage_Order use System.High_Order_First;
9574 -- If Scalar_Storage_Order is specified, it must be consistent with
9575 -- Bit_Order, so it's best to always define the latter explicitly if
9576 -- the former is used.
9577 @end smallexample
9578
9579 @noindent
9580 Other properties are as for standard representation attribute @code{Bit_Order},
9581 as defined by Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
9582
9583 For a record type @var{T}, if @code{@var{T}'Scalar_Storage_Order} is
9584 specified explicitly, it shall be equal to @code{@var{T}'Bit_Order}. Note:
9585 this means that if a @code{Scalar_Storage_Order} attribute definition
9586 clause is not confirming, then the type's @code{Bit_Order} shall be
9587 specified explicitly and set to the same value.
9588
9589 Derived types inherit an explicitly set scalar storage order from their parent
9590 types. This may be overridden for the derived type by giving an explicit scalar
9591 storage order for the derived type. For a record extension, the derived type
9592 must have the same scalar storage order as the parent type.
9593
9594 If a component of @var{T} is of a record or array type, then that type must
9595 also have a @code{Scalar_Storage_Order} attribute definition clause.
9596
9597 A component of a record or array type that is a packed array, or that
9598 does not start on a byte boundary, must have the same scalar storage order
9599 as the enclosing record or array type.
9600
9601 No component of a type that has an explicit @code{Scalar_Storage_Order}
9602 attribute definition may be aliased.
9603
9604 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
9605 with a value equal to @code{System.Default_Bit_Order}) has no effect.
9606
9607 If the opposite storage order is specified, then whenever the value of
9608 a scalar component of an object of type @var{S} is read, the storage
9609 elements of the enclosing machine scalar are first reversed (before
9610 retrieving the component value, possibly applying some shift and mask
9611 operatings on the enclosing machine scalar), and the opposite operation
9612 is done for writes.
9613
9614 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
9615 are relaxed. Instead, the following rules apply:
9616
9617 @itemize @bullet
9618 @item the underlying storage elements are those at positions
9619 @code{(position + first_bit / storage_element_size) ..
9620 (position + (last_bit + storage_element_size - 1) /
9621 storage_element_size)}
9622 @item the sequence of underlying storage elements shall have
9623 a size no greater than the largest machine scalar
9624 @item the enclosing machine scalar is defined as the smallest machine
9625 scalar starting at a position no greater than
9626 @code{position + first_bit / storage_element_size} and covering
9627 storage elements at least up to @code{position + (last_bit +
9628 storage_element_size - 1) / storage_element_size}
9629 @item the position of the component is interpreted relative to that machine
9630 scalar.
9631
9632 @end itemize
9633
9634 If no scalar storage order is specified for a type (either directly, or by
9635 inheritance in the case of a derived type), then the default is normally
9636 the native ordering of the target, but this default can be overridden using
9637 pragma @code{Default_Scalar_Storage_Order}.
9638
9639 @node Attribute Simple_Storage_Pool
9640 @unnumberedsec Attribute Simple_Storage_Pool
9641 @cindex Storage pool, simple
9642 @cindex Simple storage pool
9643 @findex Simple_Storage_Pool
9644 @noindent
9645 For every nonformal, nonderived access-to-object type @var{Acc}, the
9646 representation attribute @code{Simple_Storage_Pool} may be specified
9647 via an attribute_definition_clause (or by specifying the equivalent aspect):
9648
9649 @smallexample @c ada
9650
9651 My_Pool : My_Simple_Storage_Pool_Type;
9652
9653 type Acc is access My_Data_Type;
9654
9655 for Acc'Simple_Storage_Pool use My_Pool;
9656
9657 @end smallexample
9658
9659 @noindent
9660 The name given in an attribute_definition_clause for the
9661 @code{Simple_Storage_Pool} attribute shall denote a variable of
9662 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
9663
9664 The use of this attribute is only allowed for a prefix denoting a type
9665 for which it has been specified. The type of the attribute is the type
9666 of the variable specified as the simple storage pool of the access type,
9667 and the attribute denotes that variable.
9668
9669 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
9670 for the same access type.
9671
9672 If the @code{Simple_Storage_Pool} attribute has been specified for an access
9673 type, then applying the @code{Storage_Pool} attribute to the type is flagged
9674 with a warning and its evaluation raises the exception @code{Program_Error}.
9675
9676 If the Simple_Storage_Pool attribute has been specified for an access
9677 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
9678 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
9679 which is intended to indicate the number of storage elements reserved for
9680 the simple storage pool. If the Storage_Size function has not been defined
9681 for the simple storage pool type, then this attribute returns zero.
9682
9683 If an access type @var{S} has a specified simple storage pool of type
9684 @var{SSP}, then the evaluation of an allocator for that access type calls
9685 the primitive @code{Allocate} procedure for type @var{SSP}, passing
9686 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
9687 semantics of such allocators is the same as those defined for allocators
9688 in section 13.11 of the Ada Reference Manual, with the term
9689 ``simple storage pool'' substituted for ``storage pool''.
9690
9691 If an access type @var{S} has a specified simple storage pool of type
9692 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
9693 for that access type invokes the primitive @code{Deallocate} procedure
9694 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
9695 parameter. The detailed semantics of such unchecked deallocations is the same
9696 as defined in section 13.11.2 of the Ada Reference Manual, except that the
9697 term ``simple storage pool'' is substituted for ``storage pool''.
9698
9699 @node Attribute Small
9700 @unnumberedsec Attribute Small
9701 @cindex Ada 83 attributes
9702 @findex Small
9703 @noindent
9704 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
9705 fixed-point types.
9706 GNAT also allows this attribute to be applied to floating-point types
9707 for compatibility with Ada 83. See
9708 the Ada 83 reference manual for an exact description of the semantics of
9709 this attribute when applied to floating-point types.
9710
9711 @node Attribute Storage_Unit
9712 @unnumberedsec Attribute Storage_Unit
9713 @findex Storage_Unit
9714 @noindent
9715 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
9716 prefix) provides the same value as @code{System.Storage_Unit}.
9717
9718 @node Attribute Stub_Type
9719 @unnumberedsec Attribute Stub_Type
9720 @findex Stub_Type
9721 @noindent
9722 The GNAT implementation of remote access-to-classwide types is
9723 organized as described in AARM section E.4 (20.t): a value of an RACW type
9724 (designating a remote object) is represented as a normal access
9725 value, pointing to a "stub" object which in turn contains the
9726 necessary information to contact the designated remote object. A
9727 call on any dispatching operation of such a stub object does the
9728 remote call, if necessary, using the information in the stub object
9729 to locate the target partition, etc.
9730
9731 For a prefix @code{T} that denotes a remote access-to-classwide type,
9732 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
9733
9734 By construction, the layout of @code{T'Stub_Type} is identical to that of
9735 type @code{RACW_Stub_Type} declared in the internal implementation-defined
9736 unit @code{System.Partition_Interface}. Use of this attribute will create
9737 an implicit dependency on this unit.
9738
9739 @node Attribute System_Allocator_Alignment
9740 @unnumberedsec Attribute System_Allocator_Alignment
9741 @cindex Alignment, allocator
9742 @findex System_Allocator_Alignment
9743 @noindent
9744 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
9745 permissible prefix) provides the observable guaranted to be honored by
9746 the system allocator (malloc). This is a static value that can be used
9747 in user storage pools based on malloc either to reject allocation
9748 with alignment too large or to enable a realignment circuitry if the
9749 alignment request is larger than this value.
9750
9751 @node Attribute Target_Name
9752 @unnumberedsec Attribute Target_Name
9753 @findex Target_Name
9754 @noindent
9755 @code{Standard'Target_Name} (@code{Standard} is the only permissible
9756 prefix) provides a static string value that identifies the target
9757 for the current compilation. For GCC implementations, this is the
9758 standard gcc target name without the terminating slash (for
9759 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
9760
9761 @node Attribute To_Address
9762 @unnumberedsec Attribute To_Address
9763 @findex To_Address
9764 @noindent
9765 The @code{System'To_Address}
9766 (@code{System} is the only permissible prefix)
9767 denotes a function identical to
9768 @code{System.Storage_Elements.To_Address} except that
9769 it is a static attribute. This means that if its argument is
9770 a static expression, then the result of the attribute is a
9771 static expression. This means that such an expression can be
9772 used in contexts (e.g.@: preelaborable packages) which require a
9773 static expression and where the function call could not be used
9774 (since the function call is always non-static, even if its
9775 argument is static). The argument must be in the range
9776 -(2**(m-1) .. 2**m-1, where m is the memory size
9777 (typically 32 or 64). Negative values are intepreted in a
9778 modular manner (e.g. -1 means the same as 16#FFFF_FFFF# on
9779 a 32 bits machine).
9780
9781 @node Attribute To_Any
9782 @unnumberedsec Attribute To_Any
9783 @findex To_Any
9784 @noindent
9785 This internal attribute is used for the generation of remote subprogram
9786 stubs in the context of the Distributed Systems Annex.
9787
9788 @node Attribute Type_Class
9789 @unnumberedsec Attribute Type_Class
9790 @findex Type_Class
9791 @noindent
9792 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
9793 the value of the type class for the full type of @var{type}. If
9794 @var{type} is a generic formal type, the value is the value for the
9795 corresponding actual subtype. The value of this attribute is of type
9796 @code{System.Aux_DEC.Type_Class}, which has the following definition:
9797
9798 @smallexample @c ada
9799 type Type_Class is
9800 (Type_Class_Enumeration,
9801 Type_Class_Integer,
9802 Type_Class_Fixed_Point,
9803 Type_Class_Floating_Point,
9804 Type_Class_Array,
9805 Type_Class_Record,
9806 Type_Class_Access,
9807 Type_Class_Task,
9808 Type_Class_Address);
9809 @end smallexample
9810
9811 @noindent
9812 Protected types yield the value @code{Type_Class_Task}, which thus
9813 applies to all concurrent types. This attribute is designed to
9814 be compatible with the DEC Ada 83 attribute of the same name.
9815
9816 @node Attribute Type_Key
9817 @unnumberedsec Attribute Type_Key
9818 @findex Type_Key
9819 @noindent
9820 The @code{Type_Key} attribute is applicable to a type or subtype and
9821 yields a value of type Standard.String containing encoded information
9822 about the type or subtype. This provides improved compatibility with
9823 other implementations that support this attribute.
9824
9825 @node Attribute TypeCode
9826 @unnumberedsec Attribute TypeCode
9827 @findex TypeCode
9828 @noindent
9829 This internal attribute is used for the generation of remote subprogram
9830 stubs in the context of the Distributed Systems Annex.
9831
9832 @node Attribute UET_Address
9833 @unnumberedsec Attribute UET_Address
9834 @findex UET_Address
9835 @noindent
9836 The @code{UET_Address} attribute can only be used for a prefix which
9837 denotes a library package. It yields the address of the unit exception
9838 table when zero cost exception handling is used. This attribute is
9839 intended only for use within the GNAT implementation. See the unit
9840 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
9841 for details on how this attribute is used in the implementation.
9842
9843 @node Attribute Unconstrained_Array
9844 @unnumberedsec Attribute Unconstrained_Array
9845 @findex Unconstrained_Array
9846 @noindent
9847 The @code{Unconstrained_Array} attribute can be used with a prefix that
9848 denotes any type or subtype. It is a static attribute that yields
9849 @code{True} if the prefix designates an unconstrained array,
9850 and @code{False} otherwise. In a generic instance, the result is
9851 still static, and yields the result of applying this test to the
9852 generic actual.
9853
9854 @node Attribute Universal_Literal_String
9855 @unnumberedsec Attribute Universal_Literal_String
9856 @cindex Named numbers, representation of
9857 @findex Universal_Literal_String
9858 @noindent
9859 The prefix of @code{Universal_Literal_String} must be a named
9860 number. The static result is the string consisting of the characters of
9861 the number as defined in the original source. This allows the user
9862 program to access the actual text of named numbers without intermediate
9863 conversions and without the need to enclose the strings in quotes (which
9864 would preclude their use as numbers).
9865
9866 For example, the following program prints the first 50 digits of pi:
9867
9868 @smallexample @c ada
9869 with Text_IO; use Text_IO;
9870 with Ada.Numerics;
9871 procedure Pi is
9872 begin
9873 Put (Ada.Numerics.Pi'Universal_Literal_String);
9874 end;
9875 @end smallexample
9876
9877 @node Attribute Unrestricted_Access
9878 @unnumberedsec Attribute Unrestricted_Access
9879 @cindex @code{Access}, unrestricted
9880 @findex Unrestricted_Access
9881 @noindent
9882 The @code{Unrestricted_Access} attribute is similar to @code{Access}
9883 except that all accessibility and aliased view checks are omitted. This
9884 is a user-beware attribute.
9885
9886 For objects, it is similar to @code{Address}, for which it is a
9887 desirable replacement where the value desired is an access type.
9888 In other words, its effect is similar to first applying the
9889 @code{Address} attribute and then doing an unchecked conversion to a
9890 desired access type.
9891
9892 For subprograms, @code{P'Unrestricted_Access} may be used where
9893 @code{P'Access} would be illegal, to construct a value of a
9894 less-nested named access type that designates a more-nested
9895 subprogram. This value may be used in indirect calls, so long as the
9896 more-nested subprogram still exists; once the subprogram containing it
9897 has returned, such calls are erroneous. For example:
9898
9899 @smallexample @c ada
9900 package body P is
9901
9902 type Less_Nested is not null access procedure;
9903 Global : Less_Nested;
9904
9905 procedure P1 is
9906 begin
9907 Global.all;
9908 end P1;
9909
9910 procedure P2 is
9911 Local_Var : Integer;
9912
9913 procedure More_Nested is
9914 begin
9915 ... Local_Var ...
9916 end More_Nested;
9917 begin
9918 Global := More_Nested'Unrestricted_Access;
9919 P1;
9920 end P2;
9921
9922 end P;
9923 @end smallexample
9924
9925 When P1 is called from P2, the call via Global is OK, but if P1 were
9926 called after P2 returns, it would be an erroneous use of a dangling
9927 pointer.
9928
9929 For objects, it is possible to use @code{Unrestricted_Access} for any
9930 type, but care must be exercised if it is used to create pointers to
9931 unconstrained array objects. In this case, the resulting pointer has
9932 the same scope as the context of the attribute, and may not be
9933 returned to some enclosing scope. For instance, a function cannot use
9934 @code{Unrestricted_Access} to create a pointer to unconstrained and
9935 then return that value to the caller. In addition, it is only valid
9936 to create pointers to unconstrained arrays using this attribute if the
9937 pointer has the normal default ``fat'' representation where a pointer
9938 has two components, one points to the array and one points to the
9939 bounds. If a size clause is used to force ``thin'' representation for
9940 a pointer to unconstrained where there is only space for a single
9941 pointer, then the resulting pointer is not usable.
9942
9943 In the simple case where a direct use of Unrestricted_Access attempts
9944 to make a thin pointer for a non-aliased object, the compiler will
9945 reject the use as illegal, as shown in the following example:
9946
9947 @smallexample @c ada
9948 with System; use System;
9949 procedure SliceUA2 is
9950 type A is access all String;
9951 for A'Size use Standard'Address_Size;
9952
9953 procedure P (Arg : A) is
9954 begin
9955 null;
9956 end P;
9957
9958 X : String := "hello world!";
9959 X2 : aliased String := "hello world!";
9960
9961 AV : A := X'Unrestricted_Access; -- ERROR
9962 |
9963 >>> illegal use of Unrestricted_Access attribute
9964 >>> attempt to generate thin pointer to unaliased object
9965
9966 begin
9967 P (X'Unrestricted_Access); -- ERROR
9968 |
9969 >>> illegal use of Unrestricted_Access attribute
9970 >>> attempt to generate thin pointer to unaliased object
9971
9972 P (X(7 .. 12)'Unrestricted_Access); -- ERROR
9973 |
9974 >>> illegal use of Unrestricted_Access attribute
9975 >>> attempt to generate thin pointer to unaliased object
9976
9977 P (X2'Unrestricted_Access); -- OK
9978 end;
9979 @end smallexample
9980
9981 @noindent
9982 but other cases cannot be detected by the compiler, and are
9983 considered to be erroneous. Consider the following example:
9984
9985 @smallexample @c ada
9986 with System; use System;
9987 with System; use System;
9988 procedure SliceUA is
9989 type AF is access all String;
9990
9991 type A is access all String;
9992 for A'Size use Standard'Address_Size;
9993
9994 procedure P (Arg : A) is
9995 begin
9996 if Arg'Length /= 6 then
9997 raise Program_Error;
9998 end if;
9999 end P;
10000
10001 X : String := "hello world!";
10002 Y : AF := X (7 .. 12)'Unrestricted_Access;
10003
10004 begin
10005 P (A (Y));
10006 end;
10007 @end smallexample
10008
10009 @noindent
10010 A normal unconstrained array value
10011 or a constrained array object marked as aliased has the bounds in memory
10012 just before the array, so a thin pointer can retrieve both the data and
10013 the bounds. But in this case, the non-aliased object @code{X} does not have the
10014 bounds before the string. If the size clause for type @code{A}
10015 were not present, then the pointer
10016 would be a fat pointer, where one component is a pointer to the bounds,
10017 and all would be well. But with the size clause present, the conversion from
10018 fat pointer to thin pointer in the call loses the bounds, and so this
10019 is erroneous, and the program likely raises a @code{Program_Error} exception.
10020
10021 In general, it is advisable to completely
10022 avoid mixing the use of thin pointers and the use of
10023 @code{Unrestricted_Access} where the designated type is an
10024 unconstrained array. The use of thin pointers should be restricted to
10025 cases of porting legacy code that implicitly assumes the size of pointers,
10026 and such code should not in any case be using this attribute.
10027
10028 Another erroneous situation arises if the attribute is
10029 applied to a constant. The resulting pointer can be used to access the
10030 constant, but the effect of trying to modify a constant in this manner
10031 is not well-defined. Consider this example:
10032
10033 @smallexample @c ada
10034 P : constant Integer := 4;
10035 type R is access all Integer;
10036 RV : R := P'Unrestricted_Access;
10037 ..
10038 RV.all := 3;
10039 @end smallexample
10040
10041 @noindent
10042 Here we attempt to modify the constant P from 4 to 3, but the compiler may
10043 or may not notice this attempt, and subsequent references to P may yield
10044 either the value 3 or the value 4 or the assignment may blow up if the
10045 compiler decides to put P in read-only memory. One particular case where
10046 @code{Unrestricted_Access} can be used in this way is to modify the
10047 value of an @code{IN} parameter:
10048
10049 @smallexample @c ada
10050 procedure K (S : in String) is
10051 type R is access all Character;
10052 RV : R := S (3)'Unrestricted_Access;
10053 begin
10054 RV.all := 'a';
10055 end;
10056 @end smallexample
10057
10058 @noindent
10059 In general this is a risky approach. It may appear to "work" but such uses of
10060 @code{Unrestricted_Access} are potentially non-portable, even from one version
10061 of @code{GNAT} to another, so are best avoided if possible.
10062
10063 @node Attribute Update
10064 @unnumberedsec Attribute Update
10065 @findex Update
10066 @noindent
10067 The @code{Update} attribute creates a copy of an array or record value
10068 with one or more modified components. The syntax is:
10069
10070 @smallexample @c ada
10071 PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
10072 PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION @{, ARRAY_COMPONENT_ASSOCIATION @} )
10073 PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
10074 @{, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION @} )
10075
10076 MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
10077 INDEX_EXPRESSION_LIST_LIST ::= INDEX_EXPRESSION_LIST @{| INDEX_EXPRESSION_LIST @}
10078 INDEX_EXPRESSION_LIST ::= ( EXPRESSION @{, EXPRESSION @} )
10079 @end smallexample
10080
10081 @noindent
10082 where @code{PREFIX} is the name of an array or record object, and
10083 the association list in parentheses does not contain an @code{others}
10084 choice. The effect is to yield a copy of the array or record value which
10085 is unchanged apart from the components mentioned in the association list, which
10086 are changed to the indicated value. The original value of the array or
10087 record value is not affected. For example:
10088
10089 @smallexample @c ada
10090 type Arr is Array (1 .. 5) of Integer;
10091 ...
10092 Avar1 : Arr := (1,2,3,4,5);
10093 Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
10094 @end smallexample
10095
10096 @noindent
10097 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
10098 begin unmodified. Similarly:
10099
10100 @smallexample @c ada
10101 type Rec is A, B, C : Integer;
10102 ...
10103 Rvar1 : Rec := (A => 1, B => 2, C => 3);
10104 Rvar2 : Rec := Rvar1'Update (B => 20);
10105 @end smallexample
10106
10107 @noindent
10108 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
10109 with @code{Rvar1} being unmodifed.
10110 Note that the value of the attribute reference is computed
10111 completely before it is used. This means that if you write:
10112
10113 @smallexample @c ada
10114 Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
10115 @end smallexample
10116
10117 @noindent
10118 then the value of @code{Avar1} is not modified if @code{Function_Call}
10119 raises an exception, unlike the effect of a series of direct assignments
10120 to elements of @code{Avar1}. In general this requires that
10121 two extra complete copies of the object are required, which should be
10122 kept in mind when considering efficiency.
10123
10124 The @code{Update} attribute cannot be applied to prefixes of a limited
10125 type, and cannot reference discriminants in the case of a record type.
10126 The accessibility level of an Update attribute result object is defined
10127 as for an aggregate.
10128
10129 In the record case, no component can be mentioned more than once. In
10130 the array case, two overlapping ranges can appear in the association list,
10131 in which case the modifications are processed left to right.
10132
10133 Multi-dimensional arrays can be modified, as shown by this example:
10134
10135 @smallexample @c ada
10136 A : array (1 .. 10, 1 .. 10) of Integer;
10137 ..
10138 A := A'Update ((1, 2) => 20, (3, 4) => 30);
10139 @end smallexample
10140
10141 @noindent
10142 which changes element (1,2) to 20 and (3,4) to 30.
10143
10144 @node Attribute Valid_Scalars
10145 @unnumberedsec Attribute Valid_Scalars
10146 @findex Valid_Scalars
10147 @noindent
10148 The @code{'Valid_Scalars} attribute is intended to make it easier to
10149 check the validity of scalar subcomponents of composite objects. It
10150 is defined for any prefix @code{X} that denotes an object.
10151 The value of this attribute is of the predefined type Boolean.
10152 @code{X'Valid_Scalars} yields True if and only if evaluation of
10153 @code{P'Valid} yields True for every scalar part P of X or if X has
10154 no scalar parts. It is not specified in what order the scalar parts
10155 are checked, nor whether any more are checked after any one of them
10156 is determined to be invalid. If the prefix @code{X} is of a class-wide
10157 type @code{T'Class} (where @code{T} is the associated specific type),
10158 or if the prefix @code{X} is of a specific tagged type @code{T}, then
10159 only the scalar parts of components of @code{T} are traversed; in other
10160 words, components of extensions of @code{T} are not traversed even if
10161 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
10162 be determined at compile time that the prefix of the attribute has no
10163 scalar parts (e.g., if the prefix is of an access type, an interface type,
10164 an undiscriminated task type, or an undiscriminated protected type).
10165
10166 For scalar types, @code{Valid_Scalars} is equivalent to @code{Valid}. The use
10167 of this attribute is not permitted for @code{Unchecked_Union} types for which
10168 in general it is not possible to determine the values of the discriminants.
10169
10170 Note: @code{Valid_Scalars} can generate a lot of code, especially in the case
10171 of a large variant record. If the attribute is called in many places in the
10172 same program applied to objects of the same type, it can reduce program size
10173 to write a function with a single use of the attribute, and then call that
10174 function from multiple places.
10175
10176 @node Attribute VADS_Size
10177 @unnumberedsec Attribute VADS_Size
10178 @cindex @code{Size}, VADS compatibility
10179 @findex VADS_Size
10180 @noindent
10181 The @code{'VADS_Size} attribute is intended to make it easier to port
10182 legacy code which relies on the semantics of @code{'Size} as implemented
10183 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
10184 same semantic interpretation. In particular, @code{'VADS_Size} applied
10185 to a predefined or other primitive type with no Size clause yields the
10186 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
10187 typical machines). In addition @code{'VADS_Size} applied to an object
10188 gives the result that would be obtained by applying the attribute to
10189 the corresponding type.
10190
10191 @node Attribute Value_Size
10192 @unnumberedsec Attribute Value_Size
10193 @cindex @code{Size}, setting for not-first subtype
10194 @findex Value_Size
10195 @code{@var{type}'Value_Size} is the number of bits required to represent
10196 a value of the given subtype. It is the same as @code{@var{type}'Size},
10197 but, unlike @code{Size}, may be set for non-first subtypes.
10198
10199 @node Attribute Wchar_T_Size
10200 @unnumberedsec Attribute Wchar_T_Size
10201 @findex Wchar_T_Size
10202 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
10203 prefix) provides the size in bits of the C @code{wchar_t} type
10204 primarily for constructing the definition of this type in
10205 package @code{Interfaces.C}. The result is a static constant.
10206
10207 @node Attribute Word_Size
10208 @unnumberedsec Attribute Word_Size
10209 @findex Word_Size
10210 @code{Standard'Word_Size} (@code{Standard} is the only permissible
10211 prefix) provides the value @code{System.Word_Size}. The result is
10212 a static constant.
10213
10214 @node Standard and Implementation Defined Restrictions
10215 @chapter Standard and Implementation Defined Restrictions
10216
10217 @noindent
10218 All RM defined Restriction identifiers are implemented:
10219
10220 @itemize @bullet
10221 @item language-defined restrictions (see 13.12.1)
10222 @item tasking restrictions (see D.7)
10223 @item high integrity restrictions (see H.4)
10224 @end itemize
10225
10226 @noindent
10227 GNAT implements additional restriction identifiers. All restrictions, whether
10228 language defined or GNAT-specific, are listed in the following.
10229
10230 @menu
10231 * Partition-Wide Restrictions::
10232 * Program Unit Level Restrictions::
10233 @end menu
10234
10235 @node Partition-Wide Restrictions
10236 @section Partition-Wide Restrictions
10237
10238 There are two separate lists of restriction identifiers. The first
10239 set requires consistency throughout a partition (in other words, if the
10240 restriction identifier is used for any compilation unit in the partition,
10241 then all compilation units in the partition must obey the restriction).
10242
10243 @menu
10244 * Immediate_Reclamation::
10245 * Max_Asynchronous_Select_Nesting::
10246 * Max_Entry_Queue_Length::
10247 * Max_Protected_Entries::
10248 * Max_Select_Alternatives::
10249 * Max_Storage_At_Blocking::
10250 * Max_Task_Entries::
10251 * Max_Tasks::
10252 * No_Abort_Statements::
10253 * No_Access_Parameter_Allocators::
10254 * No_Access_Subprograms::
10255 * No_Allocators::
10256 * No_Anonymous_Allocators::
10257 * No_Calendar::
10258 * No_Coextensions::
10259 * No_Default_Initialization::
10260 * No_Delay::
10261 * No_Dependence::
10262 * No_Direct_Boolean_Operators::
10263 * No_Dispatch::
10264 * No_Dispatching_Calls::
10265 * No_Dynamic_Attachment::
10266 * No_Dynamic_Priorities::
10267 * No_Entry_Calls_In_Elaboration_Code::
10268 * No_Enumeration_Maps::
10269 * No_Exception_Handlers::
10270 * No_Exception_Propagation::
10271 * No_Exception_Registration::
10272 * No_Exceptions::
10273 * No_Finalization::
10274 * No_Fixed_Point::
10275 * No_Floating_Point::
10276 * No_Implicit_Conditionals::
10277 * No_Implicit_Dynamic_Code::
10278 * No_Implicit_Heap_Allocations::
10279 * No_Implicit_Loops::
10280 * No_Initialize_Scalars::
10281 * No_IO::
10282 * No_Local_Allocators::
10283 * No_Local_Protected_Objects::
10284 * No_Local_Timing_Events::
10285 * No_Long_Long_Integers::
10286 * No_Multiple_Elaboration::
10287 * No_Nested_Finalization::
10288 * No_Protected_Type_Allocators::
10289 * No_Protected_Types::
10290 * No_Recursion::
10291 * No_Reentrancy::
10292 * No_Relative_Delay::
10293 * No_Requeue_Statements::
10294 * No_Secondary_Stack::
10295 * No_Select_Statements::
10296 * No_Specific_Termination_Handlers::
10297 * No_Specification_of_Aspect::
10298 * No_Standard_Allocators_After_Elaboration::
10299 * No_Standard_Storage_Pools::
10300 * No_Stream_Optimizations::
10301 * No_Streams::
10302 * No_Task_Allocators::
10303 * No_Task_Attributes_Package::
10304 * No_Task_Hierarchy::
10305 * No_Task_Termination::
10306 * No_Tasking::
10307 * No_Terminate_Alternatives::
10308 * No_Unchecked_Access::
10309 * Simple_Barriers::
10310 * Static_Priorities::
10311 * Static_Storage_Size::
10312 @end menu
10313
10314 @node Immediate_Reclamation
10315 @unnumberedsubsec Immediate_Reclamation
10316 @findex Immediate_Reclamation
10317 [RM H.4] This restriction ensures that, except for storage occupied by
10318 objects created by allocators and not deallocated via unchecked
10319 deallocation, any storage reserved at run time for an object is
10320 immediately reclaimed when the object no longer exists.
10321
10322 @node Max_Asynchronous_Select_Nesting
10323 @unnumberedsubsec Max_Asynchronous_Select_Nesting
10324 @findex Max_Asynchronous_Select_Nesting
10325 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
10326 selects. Violations of this restriction with a value of zero are
10327 detected at compile time. Violations of this restriction with values
10328 other than zero cause Storage_Error to be raised.
10329
10330 @node Max_Entry_Queue_Length
10331 @unnumberedsubsec Max_Entry_Queue_Length
10332 @findex Max_Entry_Queue_Length
10333 [RM D.7] This restriction is a declaration that any protected entry compiled in
10334 the scope of the restriction has at most the specified number of
10335 tasks waiting on the entry at any one time, and so no queue is required.
10336 Note that this restriction is checked at run time. Violation of this
10337 restriction results in the raising of Program_Error exception at the point of
10338 the call.
10339
10340 @findex Max_Entry_Queue_Depth
10341 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
10342 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
10343 compatibility purposes (and a warning will be generated for its use if
10344 warnings on obsolescent features are activated).
10345
10346 @node Max_Protected_Entries
10347 @unnumberedsubsec Max_Protected_Entries
10348 @findex Max_Protected_Entries
10349 [RM D.7] Specifies the maximum number of entries per protected type. The
10350 bounds of every entry family of a protected unit shall be static, or shall be
10351 defined by a discriminant of a subtype whose corresponding bound is static.
10352
10353 @node Max_Select_Alternatives
10354 @unnumberedsubsec Max_Select_Alternatives
10355 @findex Max_Select_Alternatives
10356 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
10357
10358 @node Max_Storage_At_Blocking
10359 @unnumberedsubsec Max_Storage_At_Blocking
10360 @findex Max_Storage_At_Blocking
10361 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
10362 Storage_Size that can be retained by a blocked task. A violation of this
10363 restriction causes Storage_Error to be raised.
10364
10365 @node Max_Task_Entries
10366 @unnumberedsubsec Max_Task_Entries
10367 @findex Max_Task_Entries
10368 [RM D.7] Specifies the maximum number of entries
10369 per task. The bounds of every entry family
10370 of a task unit shall be static, or shall be
10371 defined by a discriminant of a subtype whose
10372 corresponding bound is static.
10373
10374 @node Max_Tasks
10375 @unnumberedsubsec Max_Tasks
10376 @findex Max_Tasks
10377 [RM D.7] Specifies the maximum number of task that may be created, not
10378 counting the creation of the environment task. Violations of this
10379 restriction with a value of zero are detected at compile
10380 time. Violations of this restriction with values other than zero cause
10381 Storage_Error to be raised.
10382
10383 @node No_Abort_Statements
10384 @unnumberedsubsec No_Abort_Statements
10385 @findex No_Abort_Statements
10386 [RM D.7] There are no abort_statements, and there are
10387 no calls to Task_Identification.Abort_Task.
10388
10389 @node No_Access_Parameter_Allocators
10390 @unnumberedsubsec No_Access_Parameter_Allocators
10391 @findex No_Access_Parameter_Allocators
10392 [RM H.4] This restriction ensures at compile time that there are no
10393 occurrences of an allocator as the actual parameter to an access
10394 parameter.
10395
10396 @node No_Access_Subprograms
10397 @unnumberedsubsec No_Access_Subprograms
10398 @findex No_Access_Subprograms
10399 [RM H.4] This restriction ensures at compile time that there are no
10400 declarations of access-to-subprogram types.
10401
10402 @node No_Allocators
10403 @unnumberedsubsec No_Allocators
10404 @findex No_Allocators
10405 [RM H.4] This restriction ensures at compile time that there are no
10406 occurrences of an allocator.
10407
10408 @node No_Anonymous_Allocators
10409 @unnumberedsubsec No_Anonymous_Allocators
10410 @findex No_Anonymous_Allocators
10411 [RM H.4] This restriction ensures at compile time that there are no
10412 occurrences of an allocator of anonymous access type.
10413
10414 @node No_Calendar
10415 @unnumberedsubsec No_Calendar
10416 @findex No_Calendar
10417 [GNAT] This restriction ensures at compile time that there is no implicit or
10418 explicit dependence on the package @code{Ada.Calendar}.
10419
10420 @node No_Coextensions
10421 @unnumberedsubsec No_Coextensions
10422 @findex No_Coextensions
10423 [RM H.4] This restriction ensures at compile time that there are no
10424 coextensions. See 3.10.2.
10425
10426 @node No_Default_Initialization
10427 @unnumberedsubsec No_Default_Initialization
10428 @findex No_Default_Initialization
10429
10430 [GNAT] This restriction prohibits any instance of default initialization
10431 of variables. The binder implements a consistency rule which prevents
10432 any unit compiled without the restriction from with'ing a unit with the
10433 restriction (this allows the generation of initialization procedures to
10434 be skipped, since you can be sure that no call is ever generated to an
10435 initialization procedure in a unit with the restriction active). If used
10436 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
10437 is to prohibit all cases of variables declared without a specific
10438 initializer (including the case of OUT scalar parameters).
10439
10440 @node No_Delay
10441 @unnumberedsubsec No_Delay
10442 @findex No_Delay
10443 [RM H.4] This restriction ensures at compile time that there are no
10444 delay statements and no dependences on package Calendar.
10445
10446 @node No_Dependence
10447 @unnumberedsubsec No_Dependence
10448 @findex No_Dependence
10449 [RM 13.12.1] This restriction checks at compile time that there are no
10450 dependence on a library unit.
10451
10452 @node No_Direct_Boolean_Operators
10453 @unnumberedsubsec No_Direct_Boolean_Operators
10454 @findex No_Direct_Boolean_Operators
10455 [GNAT] This restriction ensures that no logical operators (and/or/xor)
10456 are used on operands of type Boolean (or any type derived from Boolean).
10457 This is intended for use in safety critical programs where the certification
10458 protocol requires the use of short-circuit (and then, or else) forms for all
10459 composite boolean operations.
10460
10461 @node No_Dispatch
10462 @unnumberedsubsec No_Dispatch
10463 @findex No_Dispatch
10464 [RM H.4] This restriction ensures at compile time that there are no
10465 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
10466
10467 @node No_Dispatching_Calls
10468 @unnumberedsubsec No_Dispatching_Calls
10469 @findex No_Dispatching_Calls
10470 [GNAT] This restriction ensures at compile time that the code generated by the
10471 compiler involves no dispatching calls. The use of this restriction allows the
10472 safe use of record extensions, classwide membership tests and other classwide
10473 features not involving implicit dispatching. This restriction ensures that
10474 the code contains no indirect calls through a dispatching mechanism. Note that
10475 this includes internally-generated calls created by the compiler, for example
10476 in the implementation of class-wide objects assignments. The
10477 membership test is allowed in the presence of this restriction, because its
10478 implementation requires no dispatching.
10479 This restriction is comparable to the official Ada restriction
10480 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
10481 all classwide constructs that do not imply dispatching.
10482 The following example indicates constructs that violate this restriction.
10483
10484 @smallexample
10485 package Pkg is
10486 type T is tagged record
10487 Data : Natural;
10488 end record;
10489 procedure P (X : T);
10490
10491 type DT is new T with record
10492 More_Data : Natural;
10493 end record;
10494 procedure Q (X : DT);
10495 end Pkg;
10496
10497 with Pkg; use Pkg;
10498 procedure Example is
10499 procedure Test (O : T'Class) is
10500 N : Natural := O'Size;-- Error: Dispatching call
10501 C : T'Class := O; -- Error: implicit Dispatching Call
10502 begin
10503 if O in DT'Class then -- OK : Membership test
10504 Q (DT (O)); -- OK : Type conversion plus direct call
10505 else
10506 P (O); -- Error: Dispatching call
10507 end if;
10508 end Test;
10509
10510 Obj : DT;
10511 begin
10512 P (Obj); -- OK : Direct call
10513 P (T (Obj)); -- OK : Type conversion plus direct call
10514 P (T'Class (Obj)); -- Error: Dispatching call
10515
10516 Test (Obj); -- OK : Type conversion
10517
10518 if Obj in T'Class then -- OK : Membership test
10519 null;
10520 end if;
10521 end Example;
10522 @end smallexample
10523
10524 @node No_Dynamic_Attachment
10525 @unnumberedsubsec No_Dynamic_Attachment
10526 @findex No_Dynamic_Attachment
10527 [RM D.7] This restriction ensures that there is no call to any of the
10528 operations defined in package Ada.Interrupts
10529 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
10530 Detach_Handler, and Reference).
10531
10532 @findex No_Dynamic_Interrupts
10533 The restriction @code{No_Dynamic_Interrupts} is recognized as a
10534 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
10535 compatibility purposes (and a warning will be generated for its use if
10536 warnings on obsolescent features are activated).
10537
10538 @node No_Dynamic_Priorities
10539 @unnumberedsubsec No_Dynamic_Priorities
10540 @findex No_Dynamic_Priorities
10541 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
10542
10543 @node No_Entry_Calls_In_Elaboration_Code
10544 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
10545 @findex No_Entry_Calls_In_Elaboration_Code
10546 [GNAT] This restriction ensures at compile time that no task or protected entry
10547 calls are made during elaboration code. As a result of the use of this
10548 restriction, the compiler can assume that no code past an accept statement
10549 in a task can be executed at elaboration time.
10550
10551 @node No_Enumeration_Maps
10552 @unnumberedsubsec No_Enumeration_Maps
10553 @findex No_Enumeration_Maps
10554 [GNAT] This restriction ensures at compile time that no operations requiring
10555 enumeration maps are used (that is Image and Value attributes applied
10556 to enumeration types).
10557
10558 @node No_Exception_Handlers
10559 @unnumberedsubsec No_Exception_Handlers
10560 @findex No_Exception_Handlers
10561 [GNAT] This restriction ensures at compile time that there are no explicit
10562 exception handlers. It also indicates that no exception propagation will
10563 be provided. In this mode, exceptions may be raised but will result in
10564 an immediate call to the last chance handler, a routine that the user
10565 must define with the following profile:
10566
10567 @smallexample @c ada
10568 procedure Last_Chance_Handler
10569 (Source_Location : System.Address; Line : Integer);
10570 pragma Export (C, Last_Chance_Handler,
10571 "__gnat_last_chance_handler");
10572 @end smallexample
10573
10574 The parameter is a C null-terminated string representing a message to be
10575 associated with the exception (typically the source location of the raise
10576 statement generated by the compiler). The Line parameter when nonzero
10577 represents the line number in the source program where the raise occurs.
10578
10579 @node No_Exception_Propagation
10580 @unnumberedsubsec No_Exception_Propagation
10581 @findex No_Exception_Propagation
10582 [GNAT] This restriction guarantees that exceptions are never propagated
10583 to an outer subprogram scope. The only case in which an exception may
10584 be raised is when the handler is statically in the same subprogram, so
10585 that the effect of a raise is essentially like a goto statement. Any
10586 other raise statement (implicit or explicit) will be considered
10587 unhandled. Exception handlers are allowed, but may not contain an
10588 exception occurrence identifier (exception choice). In addition, use of
10589 the package GNAT.Current_Exception is not permitted, and reraise
10590 statements (raise with no operand) are not permitted.
10591
10592 @node No_Exception_Registration
10593 @unnumberedsubsec No_Exception_Registration
10594 @findex No_Exception_Registration
10595 [GNAT] This restriction ensures at compile time that no stream operations for
10596 types Exception_Id or Exception_Occurrence are used. This also makes it
10597 impossible to pass exceptions to or from a partition with this restriction
10598 in a distributed environment. If this restriction is active, the generated
10599 code is simplified by omitting the otherwise-required global registration
10600 of exceptions when they are declared.
10601
10602 @node No_Exceptions
10603 @unnumberedsubsec No_Exceptions
10604 @findex No_Exceptions
10605 [RM H.4] This restriction ensures at compile time that there are no
10606 raise statements and no exception handlers.
10607
10608 @node No_Finalization
10609 @unnumberedsubsec No_Finalization
10610 @findex No_Finalization
10611 [GNAT] This restriction disables the language features described in
10612 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
10613 performed by the compiler to support these features. The following types
10614 are no longer considered controlled when this restriction is in effect:
10615 @itemize @bullet
10616 @item
10617 @code{Ada.Finalization.Controlled}
10618 @item
10619 @code{Ada.Finalization.Limited_Controlled}
10620 @item
10621 Derivations from @code{Controlled} or @code{Limited_Controlled}
10622 @item
10623 Class-wide types
10624 @item
10625 Protected types
10626 @item
10627 Task types
10628 @item
10629 Array and record types with controlled components
10630 @end itemize
10631 The compiler no longer generates code to initialize, finalize or adjust an
10632 object or a nested component, either declared on the stack or on the heap. The
10633 deallocation of a controlled object no longer finalizes its contents.
10634
10635 @node No_Fixed_Point
10636 @unnumberedsubsec No_Fixed_Point
10637 @findex No_Fixed_Point
10638 [RM H.4] This restriction ensures at compile time that there are no
10639 occurrences of fixed point types and operations.
10640
10641 @node No_Floating_Point
10642 @unnumberedsubsec No_Floating_Point
10643 @findex No_Floating_Point
10644 [RM H.4] This restriction ensures at compile time that there are no
10645 occurrences of floating point types and operations.
10646
10647 @node No_Implicit_Conditionals
10648 @unnumberedsubsec No_Implicit_Conditionals
10649 @findex No_Implicit_Conditionals
10650 [GNAT] This restriction ensures that the generated code does not contain any
10651 implicit conditionals, either by modifying the generated code where possible,
10652 or by rejecting any construct that would otherwise generate an implicit
10653 conditional. Note that this check does not include run time constraint
10654 checks, which on some targets may generate implicit conditionals as
10655 well. To control the latter, constraint checks can be suppressed in the
10656 normal manner. Constructs generating implicit conditionals include comparisons
10657 of composite objects and the Max/Min attributes.
10658
10659 @node No_Implicit_Dynamic_Code
10660 @unnumberedsubsec No_Implicit_Dynamic_Code
10661 @findex No_Implicit_Dynamic_Code
10662 @cindex trampoline
10663 [GNAT] This restriction prevents the compiler from building ``trampolines''.
10664 This is a structure that is built on the stack and contains dynamic
10665 code to be executed at run time. On some targets, a trampoline is
10666 built for the following features: @code{Access},
10667 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
10668 nested task bodies; primitive operations of nested tagged types.
10669 Trampolines do not work on machines that prevent execution of stack
10670 data. For example, on windows systems, enabling DEP (data execution
10671 protection) will cause trampolines to raise an exception.
10672 Trampolines are also quite slow at run time.
10673
10674 On many targets, trampolines have been largely eliminated. Look at the
10675 version of system.ads for your target --- if it has
10676 Always_Compatible_Rep equal to False, then trampolines are largely
10677 eliminated. In particular, a trampoline is built for the following
10678 features: @code{Address} of a nested subprogram;
10679 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
10680 but only if pragma Favor_Top_Level applies, or the access type has a
10681 foreign-language convention; primitive operations of nested tagged
10682 types.
10683
10684 @node No_Implicit_Heap_Allocations
10685 @unnumberedsubsec No_Implicit_Heap_Allocations
10686 @findex No_Implicit_Heap_Allocations
10687 [RM D.7] No constructs are allowed to cause implicit heap allocation.
10688
10689 @node No_Implicit_Loops
10690 @unnumberedsubsec No_Implicit_Loops
10691 @findex No_Implicit_Loops
10692 [GNAT] This restriction ensures that the generated code does not contain any
10693 implicit @code{for} loops, either by modifying
10694 the generated code where possible,
10695 or by rejecting any construct that would otherwise generate an implicit
10696 @code{for} loop. If this restriction is active, it is possible to build
10697 large array aggregates with all static components without generating an
10698 intermediate temporary, and without generating a loop to initialize individual
10699 components. Otherwise, a loop is created for arrays larger than about 5000
10700 scalar components.
10701
10702 @node No_Initialize_Scalars
10703 @unnumberedsubsec No_Initialize_Scalars
10704 @findex No_Initialize_Scalars
10705 [GNAT] This restriction ensures that no unit in the partition is compiled with
10706 pragma Initialize_Scalars. This allows the generation of more efficient
10707 code, and in particular eliminates dummy null initialization routines that
10708 are otherwise generated for some record and array types.
10709
10710 @node No_IO
10711 @unnumberedsubsec No_IO
10712 @findex No_IO
10713 [RM H.4] This restriction ensures at compile time that there are no
10714 dependences on any of the library units Sequential_IO, Direct_IO,
10715 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
10716
10717 @node No_Local_Allocators
10718 @unnumberedsubsec No_Local_Allocators
10719 @findex No_Local_Allocators
10720 [RM H.4] This restriction ensures at compile time that there are no
10721 occurrences of an allocator in subprograms, generic subprograms, tasks,
10722 and entry bodies.
10723
10724 @node No_Local_Protected_Objects
10725 @unnumberedsubsec No_Local_Protected_Objects
10726 @findex No_Local_Protected_Objects
10727 [RM D.7] This restriction ensures at compile time that protected objects are
10728 only declared at the library level.
10729
10730 @node No_Local_Timing_Events
10731 @unnumberedsubsec No_Local_Timing_Events
10732 @findex No_Local_Timing_Events
10733 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
10734 declared at the library level.
10735
10736 @node No_Long_Long_Integers
10737 @unnumberedsubsec No_Long_Long_Integers
10738 @findex No_Long_Long_Integers
10739 [GNAT] This partition-wide restriction forbids any explicit reference to
10740 type Standard.Long_Long_Integer, and also forbids declaring range types whose
10741 implicit base type is Long_Long_Integer, and modular types whose size exceeds
10742 Long_Integer'Size.
10743
10744 @node No_Multiple_Elaboration
10745 @unnumberedsubsec No_Multiple_Elaboration
10746 @findex No_Multiple_Elaboration
10747 [GNAT] Normally each package contains a 16-bit counter used to check for access
10748 before elaboration, and to control multiple elaboration attempts.
10749 This counter is eliminated for units compiled with the static model
10750 of elaboration if restriction @code{No_Elaboration_Code}
10751 is active but because of
10752 the need to check for multiple elaboration in the general case, these
10753 counters cannot be eliminated if elaboration code may be present. The
10754 restriction @code{No_Multiple_Elaboration}
10755 allows suppression of these counters
10756 in static elaboration units even if they do have elaboration code. If this
10757 restriction is used, then the situations in which multiple elaboration is
10758 possible, including non-Ada main programs, and Stand Alone libraries, are not
10759 permitted, and will be diagnosed by the binder.
10760
10761 @node No_Nested_Finalization
10762 @unnumberedsubsec No_Nested_Finalization
10763 @findex No_Nested_Finalization
10764 [RM D.7] All objects requiring finalization are declared at the library level.
10765
10766 @node No_Protected_Type_Allocators
10767 @unnumberedsubsec No_Protected_Type_Allocators
10768 @findex No_Protected_Type_Allocators
10769 [RM D.7] This restriction ensures at compile time that there are no allocator
10770 expressions that attempt to allocate protected objects.
10771
10772 @node No_Protected_Types
10773 @unnumberedsubsec No_Protected_Types
10774 @findex No_Protected_Types
10775 [RM H.4] This restriction ensures at compile time that there are no
10776 declarations of protected types or protected objects.
10777
10778 @node No_Recursion
10779 @unnumberedsubsec No_Recursion
10780 @findex No_Recursion
10781 [RM H.4] A program execution is erroneous if a subprogram is invoked as
10782 part of its execution.
10783
10784 @node No_Reentrancy
10785 @unnumberedsubsec No_Reentrancy
10786 @findex No_Reentrancy
10787 [RM H.4] A program execution is erroneous if a subprogram is executed by
10788 two tasks at the same time.
10789
10790 @node No_Relative_Delay
10791 @unnumberedsubsec No_Relative_Delay
10792 @findex No_Relative_Delay
10793 [RM D.7] This restriction ensures at compile time that there are no delay
10794 relative statements and prevents expressions such as @code{delay 1.23;} from
10795 appearing in source code.
10796
10797 @node No_Requeue_Statements
10798 @unnumberedsubsec No_Requeue_Statements
10799 @findex No_Requeue_Statements
10800 [RM D.7] This restriction ensures at compile time that no requeue statements
10801 are permitted and prevents keyword @code{requeue} from being used in source
10802 code.
10803
10804 @findex No_Requeue
10805 The restriction @code{No_Requeue} is recognized as a
10806 synonym for @code{No_Requeue_Statements}. This is retained for historical
10807 compatibility purposes (and a warning will be generated for its use if
10808 warnings on oNobsolescent features are activated).
10809
10810 @node No_Secondary_Stack
10811 @unnumberedsubsec No_Secondary_Stack
10812 @findex No_Secondary_Stack
10813 [GNAT] This restriction ensures at compile time that the generated code
10814 does not contain any reference to the secondary stack. The secondary
10815 stack is used to implement functions returning unconstrained objects
10816 (arrays or records) on some targets.
10817
10818 @node No_Select_Statements
10819 @unnumberedsubsec No_Select_Statements
10820 @findex No_Select_Statements
10821 [RM D.7] This restriction ensures at compile time no select statements of any
10822 kind are permitted, that is the keyword @code{select} may not appear.
10823
10824 @node No_Specific_Termination_Handlers
10825 @unnumberedsubsec No_Specific_Termination_Handlers
10826 @findex No_Specific_Termination_Handlers
10827 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
10828 or to Ada.Task_Termination.Specific_Handler.
10829
10830 @node No_Specification_of_Aspect
10831 @unnumberedsubsec No_Specification_of_Aspect
10832 @findex No_Specification_of_Aspect
10833 [RM 13.12.1] This restriction checks at compile time that no aspect
10834 specification, attribute definition clause, or pragma is given for a
10835 given aspect.
10836
10837 @node No_Standard_Allocators_After_Elaboration
10838 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
10839 @findex No_Standard_Allocators_After_Elaboration
10840 [RM D.7] Specifies that an allocator using a standard storage pool
10841 should never be evaluated at run time after the elaboration of the
10842 library items of the partition has completed. Otherwise, Storage_Error
10843 is raised.
10844
10845 @node No_Standard_Storage_Pools
10846 @unnumberedsubsec No_Standard_Storage_Pools
10847 @findex No_Standard_Storage_Pools
10848 [GNAT] This restriction ensures at compile time that no access types
10849 use the standard default storage pool. Any access type declared must
10850 have an explicit Storage_Pool attribute defined specifying a
10851 user-defined storage pool.
10852
10853 @node No_Stream_Optimizations
10854 @unnumberedsubsec No_Stream_Optimizations
10855 @findex No_Stream_Optimizations
10856 [GNAT] This restriction affects the performance of stream operations on types
10857 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
10858 compiler uses block reads and writes when manipulating @code{String} objects
10859 due to their supperior performance. When this restriction is in effect, the
10860 compiler performs all IO operations on a per-character basis.
10861
10862 @node No_Streams
10863 @unnumberedsubsec No_Streams
10864 @findex No_Streams
10865 [GNAT] This restriction ensures at compile/bind time that there are no
10866 stream objects created and no use of stream attributes.
10867 This restriction does not forbid dependences on the package
10868 @code{Ada.Streams}. So it is permissible to with
10869 @code{Ada.Streams} (or another package that does so itself)
10870 as long as no actual stream objects are created and no
10871 stream attributes are used.
10872
10873 Note that the use of restriction allows optimization of tagged types,
10874 since they do not need to worry about dispatching stream operations.
10875 To take maximum advantage of this space-saving optimization, any
10876 unit declaring a tagged type should be compiled with the restriction,
10877 though this is not required.
10878
10879 @node No_Task_Allocators
10880 @unnumberedsubsec No_Task_Allocators
10881 @findex No_Task_Allocators
10882 [RM D.7] There are no allocators for task types
10883 or types containing task subcomponents.
10884
10885 @node No_Task_Attributes_Package
10886 @unnumberedsubsec No_Task_Attributes_Package
10887 @findex No_Task_Attributes_Package
10888 [GNAT] This restriction ensures at compile time that there are no implicit or
10889 explicit dependencies on the package @code{Ada.Task_Attributes}.
10890
10891 @findex No_Task_Attributes
10892 The restriction @code{No_Task_Attributes} is recognized as a synonym
10893 for @code{No_Task_Attributes_Package}. This is retained for historical
10894 compatibility purposes (and a warning will be generated for its use if
10895 warnings on obsolescent features are activated).
10896
10897 @node No_Task_Hierarchy
10898 @unnumberedsubsec No_Task_Hierarchy
10899 @findex No_Task_Hierarchy
10900 [RM D.7] All (non-environment) tasks depend
10901 directly on the environment task of the partition.
10902
10903 @node No_Task_Termination
10904 @unnumberedsubsec No_Task_Termination
10905 @findex No_Task_Termination
10906 [RM D.7] Tasks which terminate are erroneous.
10907
10908 @node No_Tasking
10909 @unnumberedsubsec No_Tasking
10910 @findex No_Tasking
10911 [GNAT] This restriction prevents the declaration of tasks or task types
10912 throughout the partition. It is similar in effect to the use of
10913 @code{Max_Tasks => 0} except that violations are caught at compile time
10914 and cause an error message to be output either by the compiler or
10915 binder.
10916
10917 @node No_Terminate_Alternatives
10918 @unnumberedsubsec No_Terminate_Alternatives
10919 @findex No_Terminate_Alternatives
10920 [RM D.7] There are no selective accepts with terminate alternatives.
10921
10922 @node No_Unchecked_Access
10923 @unnumberedsubsec No_Unchecked_Access
10924 @findex No_Unchecked_Access
10925 [RM H.4] This restriction ensures at compile time that there are no
10926 occurrences of the Unchecked_Access attribute.
10927
10928 @node Simple_Barriers
10929 @unnumberedsubsec Simple_Barriers
10930 @findex Simple_Barriers
10931 [RM D.7] This restriction ensures at compile time that barriers in entry
10932 declarations for protected types are restricted to either static boolean
10933 expressions or references to simple boolean variables defined in the private
10934 part of the protected type. No other form of entry barriers is permitted.
10935
10936 @findex Boolean_Entry_Barriers
10937 The restriction @code{Boolean_Entry_Barriers} is recognized as a
10938 synonym for @code{Simple_Barriers}. This is retained for historical
10939 compatibility purposes (and a warning will be generated for its use if
10940 warnings on obsolescent features are activated).
10941
10942 @node Static_Priorities
10943 @unnumberedsubsec Static_Priorities
10944 @findex Static_Priorities
10945 [GNAT] This restriction ensures at compile time that all priority expressions
10946 are static, and that there are no dependences on the package
10947 @code{Ada.Dynamic_Priorities}.
10948
10949 @node Static_Storage_Size
10950 @unnumberedsubsec Static_Storage_Size
10951 @findex Static_Storage_Size
10952 [GNAT] This restriction ensures at compile time that any expression appearing
10953 in a Storage_Size pragma or attribute definition clause is static.
10954
10955 @node Program Unit Level Restrictions
10956 @section Program Unit Level Restrictions
10957
10958 @noindent
10959 The second set of restriction identifiers
10960 does not require partition-wide consistency.
10961 The restriction may be enforced for a single
10962 compilation unit without any effect on any of the
10963 other compilation units in the partition.
10964
10965 @menu
10966 * No_Elaboration_Code::
10967 * No_Entry_Queue::
10968 * No_Implementation_Aspect_Specifications::
10969 * No_Implementation_Attributes::
10970 * No_Implementation_Identifiers::
10971 * No_Implementation_Pragmas::
10972 * No_Implementation_Restrictions::
10973 * No_Implementation_Units::
10974 * No_Implicit_Aliasing::
10975 * No_Obsolescent_Features::
10976 * No_Wide_Characters::
10977 * SPARK_05::
10978 @end menu
10979
10980 @node No_Elaboration_Code
10981 @unnumberedsubsec No_Elaboration_Code
10982 @findex No_Elaboration_Code
10983 [GNAT] This restriction ensures at compile time that no elaboration code is
10984 generated. Note that this is not the same condition as is enforced
10985 by pragma @code{Preelaborate}. There are cases in which pragma
10986 @code{Preelaborate} still permits code to be generated (e.g.@: code
10987 to initialize a large array to all zeroes), and there are cases of units
10988 which do not meet the requirements for pragma @code{Preelaborate},
10989 but for which no elaboration code is generated. Generally, it is
10990 the case that preelaborable units will meet the restrictions, with
10991 the exception of large aggregates initialized with an others_clause,
10992 and exception declarations (which generate calls to a run-time
10993 registry procedure). This restriction is enforced on
10994 a unit by unit basis, it need not be obeyed consistently
10995 throughout a partition.
10996
10997 In the case of aggregates with others, if the aggregate has a dynamic
10998 size, there is no way to eliminate the elaboration code (such dynamic
10999 bounds would be incompatible with @code{Preelaborate} in any case). If
11000 the bounds are static, then use of this restriction actually modifies
11001 the code choice of the compiler to avoid generating a loop, and instead
11002 generate the aggregate statically if possible, no matter how many times
11003 the data for the others clause must be repeatedly generated.
11004
11005 It is not possible to precisely document
11006 the constructs which are compatible with this restriction, since,
11007 unlike most other restrictions, this is not a restriction on the
11008 source code, but a restriction on the generated object code. For
11009 example, if the source contains a declaration:
11010
11011 @smallexample
11012 Val : constant Integer := X;
11013 @end smallexample
11014
11015 @noindent
11016 where X is not a static constant, it may be possible, depending
11017 on complex optimization circuitry, for the compiler to figure
11018 out the value of X at compile time, in which case this initialization
11019 can be done by the loader, and requires no initialization code. It
11020 is not possible to document the precise conditions under which the
11021 optimizer can figure this out.
11022
11023 Note that this the implementation of this restriction requires full
11024 code generation. If it is used in conjunction with "semantics only"
11025 checking, then some cases of violations may be missed.
11026
11027 @node No_Entry_Queue
11028 @unnumberedsubsec No_Entry_Queue
11029 @findex No_Entry_Queue
11030 [GNAT] This restriction is a declaration that any protected entry compiled in
11031 the scope of the restriction has at most one task waiting on the entry
11032 at any one time, and so no queue is required. This restriction is not
11033 checked at compile time. A program execution is erroneous if an attempt
11034 is made to queue a second task on such an entry.
11035
11036 @node No_Implementation_Aspect_Specifications
11037 @unnumberedsubsec No_Implementation_Aspect_Specifications
11038 @findex No_Implementation_Aspect_Specifications
11039 [RM 13.12.1] This restriction checks at compile time that no
11040 GNAT-defined aspects are present. With this restriction, the only
11041 aspects that can be used are those defined in the Ada Reference Manual.
11042
11043 @node No_Implementation_Attributes
11044 @unnumberedsubsec No_Implementation_Attributes
11045 @findex No_Implementation_Attributes
11046 [RM 13.12.1] This restriction checks at compile time that no
11047 GNAT-defined attributes are present. With this restriction, the only
11048 attributes that can be used are those defined in the Ada Reference
11049 Manual.
11050
11051 @node No_Implementation_Identifiers
11052 @unnumberedsubsec No_Implementation_Identifiers
11053 @findex No_Implementation_Identifiers
11054 [RM 13.12.1] This restriction checks at compile time that no
11055 implementation-defined identifiers (marked with pragma Implementation_Defined)
11056 occur within language-defined packages.
11057
11058 @node No_Implementation_Pragmas
11059 @unnumberedsubsec No_Implementation_Pragmas
11060 @findex No_Implementation_Pragmas
11061 [RM 13.12.1] This restriction checks at compile time that no
11062 GNAT-defined pragmas are present. With this restriction, the only
11063 pragmas that can be used are those defined in the Ada Reference Manual.
11064
11065 @node No_Implementation_Restrictions
11066 @unnumberedsubsec No_Implementation_Restrictions
11067 @findex No_Implementation_Restrictions
11068 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
11069 identifiers (other than @code{No_Implementation_Restrictions} itself)
11070 are present. With this restriction, the only other restriction identifiers
11071 that can be used are those defined in the Ada Reference Manual.
11072
11073 @node No_Implementation_Units
11074 @unnumberedsubsec No_Implementation_Units
11075 @findex No_Implementation_Units
11076 [RM 13.12.1] This restriction checks at compile time that there is no
11077 mention in the context clause of any implementation-defined descendants
11078 of packages Ada, Interfaces, or System.
11079
11080 @node No_Implicit_Aliasing
11081 @unnumberedsubsec No_Implicit_Aliasing
11082 @findex No_Implicit_Aliasing
11083 [GNAT] This restriction, which is not required to be partition-wide consistent,
11084 requires an explicit aliased keyword for an object to which 'Access,
11085 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
11086 the 'Unrestricted_Access attribute for objects. Note: the reason that
11087 Unrestricted_Access is forbidden is that it would require the prefix
11088 to be aliased, and in such cases, it can always be replaced by
11089 the standard attribute Unchecked_Access which is preferable.
11090
11091 @node No_Obsolescent_Features
11092 @unnumberedsubsec No_Obsolescent_Features
11093 @findex No_Obsolescent_Features
11094 [RM 13.12.1] This restriction checks at compile time that no obsolescent
11095 features are used, as defined in Annex J of the Ada Reference Manual.
11096
11097 @node No_Wide_Characters
11098 @unnumberedsubsec No_Wide_Characters
11099 @findex No_Wide_Characters
11100 [GNAT] This restriction ensures at compile time that no uses of the types
11101 @code{Wide_Character} or @code{Wide_String} or corresponding wide
11102 wide types
11103 appear, and that no wide or wide wide string or character literals
11104 appear in the program (that is literals representing characters not in
11105 type @code{Character}).
11106
11107 @node SPARK_05
11108 @unnumberedsubsec SPARK_05
11109 @findex SPARK_05
11110 [GNAT] This restriction checks at compile time that some constructs
11111 forbidden in SPARK 2005 are not present. Error messages related to
11112 SPARK restriction have the form:
11113
11114 @smallexample
11115 violation of restriction "SPARK_05" at <source-location>
11116 <error message>
11117 @end smallexample
11118
11119 @findex SPARK
11120 The restriction @code{SPARK} is recognized as a
11121 synonym for @code{SPARK_05}. This is retained for historical
11122 compatibility purposes (and an unconditional warning will be generated
11123 for its use, advising replacement by @code{SPARK}).
11124
11125 This is not a replacement for the semantic checks performed by the
11126 SPARK Examiner tool, as the compiler currently only deals with code,
11127 not SPARK 2005 annotations, and does not guarantee catching all
11128 cases of constructs forbidden by SPARK 2005.
11129
11130 Thus it may well be the case that code which passes the compiler with
11131 the SPARK restriction is rejected by the SPARK Examiner, e.g. due to
11132 the different visibility rules of the Examiner based on SPARK 2005
11133 @code{inherit} annotations.
11134
11135 This restriction can be useful in providing an initial filter for code
11136 developed using SPARK 2005, or in examining legacy code to see how far
11137 it is from meeting SPARK restrictions.
11138
11139 The list below summarizes the checks that are performed when this
11140 restriction is in force:
11141 @itemize @bullet
11142 @item No block statements
11143 @item No case statements with only an others clause
11144 @item Exit statements in loops must respect the SPARK 2005 language restrictions
11145 @item No goto statements
11146 @item Return can only appear as last statement in function
11147 @item Function must have return statement
11148 @item Loop parameter specification must include subtype mark
11149 @item Prefix of expanded name cannot be a loop statement
11150 @item Abstract subprogram not allowed
11151 @item User-defined operators not allowed
11152 @item Access type parameters not allowed
11153 @item Default expressions for parameters not allowed
11154 @item Default expressions for record fields not allowed
11155 @item No tasking constructs allowed
11156 @item Label needed at end of subprograms and packages
11157 @item No mixing of positional and named parameter association
11158 @item No access types as result type
11159 @item No unconstrained arrays as result types
11160 @item No null procedures
11161 @item Initial and later declarations must be in correct order (declaration can't come after body)
11162 @item No attributes on private types if full declaration not visible
11163 @item No package declaration within package specification
11164 @item No controlled types
11165 @item No discriminant types
11166 @item No overloading
11167 @item Selector name cannot be operator symbol (i.e. operator symbol cannot be prefixed)
11168 @item Access attribute not allowed
11169 @item Allocator not allowed
11170 @item Result of catenation must be String
11171 @item Operands of catenation must be string literal, static char or another catenation
11172 @item No conditional expressions
11173 @item No explicit dereference
11174 @item Quantified expression not allowed
11175 @item Slicing not allowed
11176 @item No exception renaming
11177 @item No generic renaming
11178 @item No object renaming
11179 @item No use clause
11180 @item Aggregates must be qualified
11181 @item Non-static choice in array aggregates not allowed
11182 @item The only view conversions which are allowed as in-out parameters are conversions of a tagged type to an ancestor type
11183 @item No mixing of positional and named association in aggregate, no multi choice
11184 @item AND, OR and XOR for arrays only allowed when operands have same static bounds
11185 @item Fixed point operands to * or / must be qualified or converted
11186 @item Comparison operators not allowed for Booleans or arrays (except strings)
11187 @item Equality not allowed for arrays with non-matching static bounds (except strings)
11188 @item Conversion / qualification not allowed for arrays with non-matching static bounds
11189 @item Subprogram declaration only allowed in package spec (unless followed by import)
11190 @item Access types not allowed
11191 @item Incomplete type declaration not allowed
11192 @item Object and subtype declarations must respect SPARK restrictions
11193 @item Digits or delta constraint not allowed
11194 @item Decimal fixed point type not allowed
11195 @item Aliasing of objects not allowed
11196 @item Modular type modulus must be power of 2
11197 @item Base not allowed on subtype mark
11198 @item Unary operators not allowed on modular types (except not)
11199 @item Untagged record cannot be null
11200 @item No class-wide operations
11201 @item Initialization expressions must respect SPARK restrictions
11202 @item Non-static ranges not allowed except in iteration schemes
11203 @item String subtypes must have lower bound of 1
11204 @item Subtype of Boolean cannot have constraint
11205 @item At most one tagged type or extension per package
11206 @item Interface is not allowed
11207 @item Character literal cannot be prefixed (selector name cannot be character literal)
11208 @item Record aggregate cannot contain 'others'
11209 @item Component association in record aggregate must contain a single choice
11210 @item Ancestor part cannot be a type mark
11211 @item Attributes 'Image, 'Width and 'Value not allowed
11212 @item Functions may not update globals
11213 @item Subprograms may not contain direct calls to themselves (prevents recursion within unit)
11214 @item Call to subprogram not allowed in same unit before body has been seen (prevents recursion within unit)
11215 @end itemize
11216
11217 The following restrictions are enforced, but note that they are actually more
11218 strict that the latest SPARK 2005 language definition:
11219
11220 @itemize @bullet
11221 @item No derived types other than tagged type extensions
11222 @item Subtype of unconstrained array must have constraint
11223 @end itemize
11224
11225 This list summarises the main SPARK 2005 language rules that are not
11226 currently checked by the SPARK_05 restriction:
11227
11228 @itemize @bullet
11229 @item SPARK annotations are treated as comments so are not checked at all
11230 @item Based real literals not allowed
11231 @item Objects cannot be initialized at declaration by calls to user-defined functions
11232 @item Objects cannot be initialized at declaration by assignments from variables
11233 @item Objects cannot be initialized at declaration by assignments from indexed/selected components
11234 @item Ranges shall not be null
11235 @item A fixed point delta expression must be a simple expression
11236 @item Restrictions on where renaming declarations may be placed
11237 @item Externals of mode 'out' cannot be referenced
11238 @item Externals of mode 'in' cannot be updated
11239 @item Loop with no iteration scheme or exits only allowed as last statement in main program or task
11240 @item Subprogram cannot have parent unit name
11241 @item SPARK 2005 inherited subprogram must be prefixed with overriding
11242 @item External variables (or functions that reference them) may not be passed as actual parameters
11243 @item Globals must be explicitly mentioned in contract
11244 @item Deferred constants cannot be completed by pragma Import
11245 @item Package initialization cannot read/write variables from other packages
11246 @item Prefix not allowed for entities that are directly visible
11247 @item Identifier declaration can't override inherited package name
11248 @item Cannot use Standard or other predefined packages as identifiers
11249 @item After renaming, cannot use the original name
11250 @item Subprograms can only be renamed to remove package prefix
11251 @item Pragma import must be immediately after entity it names
11252 @item No mutual recursion between multiple units (this can be checked with gnatcheck)
11253 @end itemize
11254
11255 Note that if a unit is compiled in Ada 95 mode with the SPARK restriction,
11256 violations will be reported for constructs forbidden in SPARK 95,
11257 instead of SPARK 2005.
11258
11259 @c ------------------------
11260 @node Implementation Advice
11261 @chapter Implementation Advice
11262 @noindent
11263 The main text of the Ada Reference Manual describes the required
11264 behavior of all Ada compilers, and the GNAT compiler conforms to
11265 these requirements.
11266
11267 In addition, there are sections throughout the Ada Reference Manual headed
11268 by the phrase ``Implementation advice''. These sections are not normative,
11269 i.e., they do not specify requirements that all compilers must
11270 follow. Rather they provide advice on generally desirable behavior. You
11271 may wonder why they are not requirements. The most typical answer is
11272 that they describe behavior that seems generally desirable, but cannot
11273 be provided on all systems, or which may be undesirable on some systems.
11274
11275 As far as practical, GNAT follows the implementation advice sections in
11276 the Ada Reference Manual. This chapter contains a table giving the
11277 reference manual section number, paragraph number and several keywords
11278 for each advice. Each entry consists of the text of the advice followed
11279 by the GNAT interpretation of this advice. Most often, this simply says
11280 ``followed'', which means that GNAT follows the advice. However, in a
11281 number of cases, GNAT deliberately deviates from this advice, in which
11282 case the text describes what GNAT does and why.
11283
11284 @cindex Error detection
11285 @unnumberedsec 1.1.3(20): Error Detection
11286 @sp 1
11287 @cartouche
11288 If an implementation detects the use of an unsupported Specialized Needs
11289 Annex feature at run time, it should raise @code{Program_Error} if
11290 feasible.
11291 @end cartouche
11292 Not relevant. All specialized needs annex features are either supported,
11293 or diagnosed at compile time.
11294
11295 @cindex Child Units
11296 @unnumberedsec 1.1.3(31): Child Units
11297 @sp 1
11298 @cartouche
11299 If an implementation wishes to provide implementation-defined
11300 extensions to the functionality of a language-defined library unit, it
11301 should normally do so by adding children to the library unit.
11302 @end cartouche
11303 Followed.
11304
11305 @cindex Bounded errors
11306 @unnumberedsec 1.1.5(12): Bounded Errors
11307 @sp 1
11308 @cartouche
11309 If an implementation detects a bounded error or erroneous
11310 execution, it should raise @code{Program_Error}.
11311 @end cartouche
11312 Followed in all cases in which the implementation detects a bounded
11313 error or erroneous execution. Not all such situations are detected at
11314 runtime.
11315
11316 @cindex Pragmas
11317 @unnumberedsec 2.8(16): Pragmas
11318 @sp 1
11319 @cartouche
11320 Normally, implementation-defined pragmas should have no semantic effect
11321 for error-free programs; that is, if the implementation-defined pragmas
11322 are removed from a working program, the program should still be legal,
11323 and should still have the same semantics.
11324 @end cartouche
11325 The following implementation defined pragmas are exceptions to this
11326 rule:
11327
11328 @table @code
11329 @item Abort_Defer
11330 Affects semantics
11331 @item Ada_83
11332 Affects legality
11333 @item Assert
11334 Affects semantics
11335 @item CPP_Class
11336 Affects semantics
11337 @item CPP_Constructor
11338 Affects semantics
11339 @item Debug
11340 Affects semantics
11341 @item Interface_Name
11342 Affects semantics
11343 @item Machine_Attribute
11344 Affects semantics
11345 @item Unimplemented_Unit
11346 Affects legality
11347 @item Unchecked_Union
11348 Affects semantics
11349 @end table
11350
11351 @noindent
11352 In each of the above cases, it is essential to the purpose of the pragma
11353 that this advice not be followed. For details see the separate section
11354 on implementation defined pragmas.
11355
11356 @unnumberedsec 2.8(17-19): Pragmas
11357 @sp 1
11358 @cartouche
11359 Normally, an implementation should not define pragmas that can
11360 make an illegal program legal, except as follows:
11361 @end cartouche
11362 @sp 1
11363 @cartouche
11364 A pragma used to complete a declaration, such as a pragma @code{Import};
11365 @end cartouche
11366 @sp 1
11367 @cartouche
11368 A pragma used to configure the environment by adding, removing, or
11369 replacing @code{library_items}.
11370 @end cartouche
11371 See response to paragraph 16 of this same section.
11372
11373 @cindex Character Sets
11374 @cindex Alternative Character Sets
11375 @unnumberedsec 3.5.2(5): Alternative Character Sets
11376 @sp 1
11377 @cartouche
11378 If an implementation supports a mode with alternative interpretations
11379 for @code{Character} and @code{Wide_Character}, the set of graphic
11380 characters of @code{Character} should nevertheless remain a proper
11381 subset of the set of graphic characters of @code{Wide_Character}. Any
11382 character set ``localizations'' should be reflected in the results of
11383 the subprograms defined in the language-defined package
11384 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
11385 an alternative interpretation of @code{Character}, the implementation should
11386 also support a corresponding change in what is a legal
11387 @code{identifier_letter}.
11388 @end cartouche
11389 Not all wide character modes follow this advice, in particular the JIS
11390 and IEC modes reflect standard usage in Japan, and in these encoding,
11391 the upper half of the Latin-1 set is not part of the wide-character
11392 subset, since the most significant bit is used for wide character
11393 encoding. However, this only applies to the external forms. Internally
11394 there is no such restriction.
11395
11396 @cindex Integer types
11397 @unnumberedsec 3.5.4(28): Integer Types
11398
11399 @sp 1
11400 @cartouche
11401 An implementation should support @code{Long_Integer} in addition to
11402 @code{Integer} if the target machine supports 32-bit (or longer)
11403 arithmetic. No other named integer subtypes are recommended for package
11404 @code{Standard}. Instead, appropriate named integer subtypes should be
11405 provided in the library package @code{Interfaces} (see B.2).
11406 @end cartouche
11407 @code{Long_Integer} is supported. Other standard integer types are supported
11408 so this advice is not fully followed. These types
11409 are supported for convenient interface to C, and so that all hardware
11410 types of the machine are easily available.
11411 @unnumberedsec 3.5.4(29): Integer Types
11412
11413 @sp 1
11414 @cartouche
11415 An implementation for a two's complement machine should support
11416 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
11417 implementation should support a non-binary modules up to @code{Integer'Last}.
11418 @end cartouche
11419 Followed.
11420
11421 @cindex Enumeration values
11422 @unnumberedsec 3.5.5(8): Enumeration Values
11423 @sp 1
11424 @cartouche
11425 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
11426 subtype, if the value of the operand does not correspond to the internal
11427 code for any enumeration literal of its type (perhaps due to an
11428 un-initialized variable), then the implementation should raise
11429 @code{Program_Error}. This is particularly important for enumeration
11430 types with noncontiguous internal codes specified by an
11431 enumeration_representation_clause.
11432 @end cartouche
11433 Followed.
11434
11435 @cindex Float types
11436 @unnumberedsec 3.5.7(17): Float Types
11437 @sp 1
11438 @cartouche
11439 An implementation should support @code{Long_Float} in addition to
11440 @code{Float} if the target machine supports 11 or more digits of
11441 precision. No other named floating point subtypes are recommended for
11442 package @code{Standard}. Instead, appropriate named floating point subtypes
11443 should be provided in the library package @code{Interfaces} (see B.2).
11444 @end cartouche
11445 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
11446 former provides improved compatibility with other implementations
11447 supporting this type. The latter corresponds to the highest precision
11448 floating-point type supported by the hardware. On most machines, this
11449 will be the same as @code{Long_Float}, but on some machines, it will
11450 correspond to the IEEE extended form. The notable case is all ia32
11451 (x86) implementations, where @code{Long_Long_Float} corresponds to
11452 the 80-bit extended precision format supported in hardware on this
11453 processor. Note that the 128-bit format on SPARC is not supported,
11454 since this is a software rather than a hardware format.
11455
11456 @cindex Multidimensional arrays
11457 @cindex Arrays, multidimensional
11458 @unnumberedsec 3.6.2(11): Multidimensional Arrays
11459 @sp 1
11460 @cartouche
11461 An implementation should normally represent multidimensional arrays in
11462 row-major order, consistent with the notation used for multidimensional
11463 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
11464 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
11465 column-major order should be used instead (see B.5, ``Interfacing with
11466 Fortran'').
11467 @end cartouche
11468 Followed.
11469
11470 @findex Duration'Small
11471 @unnumberedsec 9.6(30-31): Duration'Small
11472 @sp 1
11473 @cartouche
11474 Whenever possible in an implementation, the value of @code{Duration'Small}
11475 should be no greater than 100 microseconds.
11476 @end cartouche
11477 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
11478
11479 @sp 1
11480 @cartouche
11481 The time base for @code{delay_relative_statements} should be monotonic;
11482 it need not be the same time base as used for @code{Calendar.Clock}.
11483 @end cartouche
11484 Followed.
11485
11486 @unnumberedsec 10.2.1(12): Consistent Representation
11487 @sp 1
11488 @cartouche
11489 In an implementation, a type declared in a pre-elaborated package should
11490 have the same representation in every elaboration of a given version of
11491 the package, whether the elaborations occur in distinct executions of
11492 the same program, or in executions of distinct programs or partitions
11493 that include the given version.
11494 @end cartouche
11495 Followed, except in the case of tagged types. Tagged types involve
11496 implicit pointers to a local copy of a dispatch table, and these pointers
11497 have representations which thus depend on a particular elaboration of the
11498 package. It is not easy to see how it would be possible to follow this
11499 advice without severely impacting efficiency of execution.
11500
11501 @cindex Exception information
11502 @unnumberedsec 11.4.1(19): Exception Information
11503 @sp 1
11504 @cartouche
11505 @code{Exception_Message} by default and @code{Exception_Information}
11506 should produce information useful for
11507 debugging. @code{Exception_Message} should be short, about one
11508 line. @code{Exception_Information} can be long. @code{Exception_Message}
11509 should not include the
11510 @code{Exception_Name}. @code{Exception_Information} should include both
11511 the @code{Exception_Name} and the @code{Exception_Message}.
11512 @end cartouche
11513 Followed. For each exception that doesn't have a specified
11514 @code{Exception_Message}, the compiler generates one containing the location
11515 of the raise statement. This location has the form ``file:line'', where
11516 file is the short file name (without path information) and line is the line
11517 number in the file. Note that in the case of the Zero Cost Exception
11518 mechanism, these messages become redundant with the Exception_Information that
11519 contains a full backtrace of the calling sequence, so they are disabled.
11520 To disable explicitly the generation of the source location message, use the
11521 Pragma @code{Discard_Names}.
11522
11523 @cindex Suppression of checks
11524 @cindex Checks, suppression of
11525 @unnumberedsec 11.5(28): Suppression of Checks
11526 @sp 1
11527 @cartouche
11528 The implementation should minimize the code executed for checks that
11529 have been suppressed.
11530 @end cartouche
11531 Followed.
11532
11533 @cindex Representation clauses
11534 @unnumberedsec 13.1 (21-24): Representation Clauses
11535 @sp 1
11536 @cartouche
11537 The recommended level of support for all representation items is
11538 qualified as follows:
11539 @end cartouche
11540 @sp 1
11541 @cartouche
11542 An implementation need not support representation items containing
11543 non-static expressions, except that an implementation should support a
11544 representation item for a given entity if each non-static expression in
11545 the representation item is a name that statically denotes a constant
11546 declared before the entity.
11547 @end cartouche
11548 Followed. In fact, GNAT goes beyond the recommended level of support
11549 by allowing nonstatic expressions in some representation clauses even
11550 without the need to declare constants initialized with the values of
11551 such expressions.
11552 For example:
11553
11554 @smallexample @c ada
11555 X : Integer;
11556 Y : Float;
11557 for Y'Address use X'Address;>>
11558 @end smallexample
11559
11560 @sp 1
11561 @cartouche
11562 An implementation need not support a specification for the @code{Size}
11563 for a given composite subtype, nor the size or storage place for an
11564 object (including a component) of a given composite subtype, unless the
11565 constraints on the subtype and its composite subcomponents (if any) are
11566 all static constraints.
11567 @end cartouche
11568 Followed. Size Clauses are not permitted on non-static components, as
11569 described above.
11570
11571 @sp 1
11572 @cartouche
11573 An aliased component, or a component whose type is by-reference, should
11574 always be allocated at an addressable location.
11575 @end cartouche
11576 Followed.
11577
11578 @cindex Packed types
11579 @unnumberedsec 13.2(6-8): Packed Types
11580 @sp 1
11581 @cartouche
11582 If a type is packed, then the implementation should try to minimize
11583 storage allocated to objects of the type, possibly at the expense of
11584 speed of accessing components, subject to reasonable complexity in
11585 addressing calculations.
11586 @end cartouche
11587 @sp 1
11588 @cartouche
11589 The recommended level of support pragma @code{Pack} is:
11590
11591 For a packed record type, the components should be packed as tightly as
11592 possible subject to the Sizes of the component subtypes, and subject to
11593 any @code{record_representation_clause} that applies to the type; the
11594 implementation may, but need not, reorder components or cross aligned
11595 word boundaries to improve the packing. A component whose @code{Size} is
11596 greater than the word size may be allocated an integral number of words.
11597 @end cartouche
11598 Followed. Tight packing of arrays is supported for all component sizes
11599 up to 64-bits. If the array component size is 1 (that is to say, if
11600 the component is a boolean type or an enumeration type with two values)
11601 then values of the type are implicitly initialized to zero. This
11602 happens both for objects of the packed type, and for objects that have a
11603 subcomponent of the packed type.
11604
11605 @sp 1
11606 @cartouche
11607 An implementation should support Address clauses for imported
11608 subprograms.
11609 @end cartouche
11610 Followed.
11611 @cindex @code{Address} clauses
11612 @unnumberedsec 13.3(14-19): Address Clauses
11613
11614 @sp 1
11615 @cartouche
11616 For an array @var{X}, @code{@var{X}'Address} should point at the first
11617 component of the array, and not at the array bounds.
11618 @end cartouche
11619 Followed.
11620
11621 @sp 1
11622 @cartouche
11623 The recommended level of support for the @code{Address} attribute is:
11624
11625 @code{@var{X}'Address} should produce a useful result if @var{X} is an
11626 object that is aliased or of a by-reference type, or is an entity whose
11627 @code{Address} has been specified.
11628 @end cartouche
11629 Followed. A valid address will be produced even if none of those
11630 conditions have been met. If necessary, the object is forced into
11631 memory to ensure the address is valid.
11632
11633 @sp 1
11634 @cartouche
11635 An implementation should support @code{Address} clauses for imported
11636 subprograms.
11637 @end cartouche
11638 Followed.
11639
11640 @sp 1
11641 @cartouche
11642 Objects (including subcomponents) that are aliased or of a by-reference
11643 type should be allocated on storage element boundaries.
11644 @end cartouche
11645 Followed.
11646
11647 @sp 1
11648 @cartouche
11649 If the @code{Address} of an object is specified, or it is imported or exported,
11650 then the implementation should not perform optimizations based on
11651 assumptions of no aliases.
11652 @end cartouche
11653 Followed.
11654
11655 @cindex @code{Alignment} clauses
11656 @unnumberedsec 13.3(29-35): Alignment Clauses
11657 @sp 1
11658 @cartouche
11659 The recommended level of support for the @code{Alignment} attribute for
11660 subtypes is:
11661
11662 An implementation should support specified Alignments that are factors
11663 and multiples of the number of storage elements per word, subject to the
11664 following:
11665 @end cartouche
11666 Followed.
11667
11668 @sp 1
11669 @cartouche
11670 An implementation need not support specified @code{Alignment}s for
11671 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
11672 loaded and stored by available machine instructions.
11673 @end cartouche
11674 Followed.
11675
11676 @sp 1
11677 @cartouche
11678 An implementation need not support specified @code{Alignment}s that are
11679 greater than the maximum @code{Alignment} the implementation ever returns by
11680 default.
11681 @end cartouche
11682 Followed.
11683
11684 @sp 1
11685 @cartouche
11686 The recommended level of support for the @code{Alignment} attribute for
11687 objects is:
11688
11689 Same as above, for subtypes, but in addition:
11690 @end cartouche
11691 Followed.
11692
11693 @sp 1
11694 @cartouche
11695 For stand-alone library-level objects of statically constrained
11696 subtypes, the implementation should support all @code{Alignment}s
11697 supported by the target linker. For example, page alignment is likely to
11698 be supported for such objects, but not for subtypes.
11699 @end cartouche
11700 Followed.
11701
11702 @cindex @code{Size} clauses
11703 @unnumberedsec 13.3(42-43): Size Clauses
11704 @sp 1
11705 @cartouche
11706 The recommended level of support for the @code{Size} attribute of
11707 objects is:
11708
11709 A @code{Size} clause should be supported for an object if the specified
11710 @code{Size} is at least as large as its subtype's @code{Size}, and
11711 corresponds to a size in storage elements that is a multiple of the
11712 object's @code{Alignment} (if the @code{Alignment} is nonzero).
11713 @end cartouche
11714 Followed.
11715
11716 @unnumberedsec 13.3(50-56): Size Clauses
11717 @sp 1
11718 @cartouche
11719 If the @code{Size} of a subtype is specified, and allows for efficient
11720 independent addressability (see 9.10) on the target architecture, then
11721 the @code{Size} of the following objects of the subtype should equal the
11722 @code{Size} of the subtype:
11723
11724 Aliased objects (including components).
11725 @end cartouche
11726 Followed.
11727
11728 @sp 1
11729 @cartouche
11730 @code{Size} clause on a composite subtype should not affect the
11731 internal layout of components.
11732 @end cartouche
11733 Followed. But note that this can be overridden by use of the implementation
11734 pragma Implicit_Packing in the case of packed arrays.
11735
11736 @sp 1
11737 @cartouche
11738 The recommended level of support for the @code{Size} attribute of subtypes is:
11739 @end cartouche
11740 @sp 1
11741 @cartouche
11742 The @code{Size} (if not specified) of a static discrete or fixed point
11743 subtype should be the number of bits needed to represent each value
11744 belonging to the subtype using an unbiased representation, leaving space
11745 for a sign bit only if the subtype contains negative values. If such a
11746 subtype is a first subtype, then an implementation should support a
11747 specified @code{Size} for it that reflects this representation.
11748 @end cartouche
11749 Followed.
11750
11751 @sp 1
11752 @cartouche
11753 For a subtype implemented with levels of indirection, the @code{Size}
11754 should include the size of the pointers, but not the size of what they
11755 point at.
11756 @end cartouche
11757 Followed.
11758
11759 @cindex @code{Component_Size} clauses
11760 @unnumberedsec 13.3(71-73): Component Size Clauses
11761 @sp 1
11762 @cartouche
11763 The recommended level of support for the @code{Component_Size}
11764 attribute is:
11765 @end cartouche
11766 @sp 1
11767 @cartouche
11768 An implementation need not support specified @code{Component_Sizes} that are
11769 less than the @code{Size} of the component subtype.
11770 @end cartouche
11771 Followed.
11772
11773 @sp 1
11774 @cartouche
11775 An implementation should support specified @code{Component_Size}s that
11776 are factors and multiples of the word size. For such
11777 @code{Component_Size}s, the array should contain no gaps between
11778 components. For other @code{Component_Size}s (if supported), the array
11779 should contain no gaps between components when packing is also
11780 specified; the implementation should forbid this combination in cases
11781 where it cannot support a no-gaps representation.
11782 @end cartouche
11783 Followed.
11784
11785 @cindex Enumeration representation clauses
11786 @cindex Representation clauses, enumeration
11787 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
11788 @sp 1
11789 @cartouche
11790 The recommended level of support for enumeration representation clauses
11791 is:
11792
11793 An implementation need not support enumeration representation clauses
11794 for boolean types, but should at minimum support the internal codes in
11795 the range @code{System.Min_Int.System.Max_Int}.
11796 @end cartouche
11797 Followed.
11798
11799 @cindex Record representation clauses
11800 @cindex Representation clauses, records
11801 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
11802 @sp 1
11803 @cartouche
11804 The recommended level of support for
11805 @*@code{record_representation_clauses} is:
11806
11807 An implementation should support storage places that can be extracted
11808 with a load, mask, shift sequence of machine code, and set with a load,
11809 shift, mask, store sequence, given the available machine instructions
11810 and run-time model.
11811 @end cartouche
11812 Followed.
11813
11814 @sp 1
11815 @cartouche
11816 A storage place should be supported if its size is equal to the
11817 @code{Size} of the component subtype, and it starts and ends on a
11818 boundary that obeys the @code{Alignment} of the component subtype.
11819 @end cartouche
11820 Followed.
11821
11822 @sp 1
11823 @cartouche
11824 If the default bit ordering applies to the declaration of a given type,
11825 then for a component whose subtype's @code{Size} is less than the word
11826 size, any storage place that does not cross an aligned word boundary
11827 should be supported.
11828 @end cartouche
11829 Followed.
11830
11831 @sp 1
11832 @cartouche
11833 An implementation may reserve a storage place for the tag field of a
11834 tagged type, and disallow other components from overlapping that place.
11835 @end cartouche
11836 Followed. The storage place for the tag field is the beginning of the tagged
11837 record, and its size is Address'Size. GNAT will reject an explicit component
11838 clause for the tag field.
11839
11840 @sp 1
11841 @cartouche
11842 An implementation need not support a @code{component_clause} for a
11843 component of an extension part if the storage place is not after the
11844 storage places of all components of the parent type, whether or not
11845 those storage places had been specified.
11846 @end cartouche
11847 Followed. The above advice on record representation clauses is followed,
11848 and all mentioned features are implemented.
11849
11850 @cindex Storage place attributes
11851 @unnumberedsec 13.5.2(5): Storage Place Attributes
11852 @sp 1
11853 @cartouche
11854 If a component is represented using some form of pointer (such as an
11855 offset) to the actual data of the component, and this data is contiguous
11856 with the rest of the object, then the storage place attributes should
11857 reflect the place of the actual data, not the pointer. If a component is
11858 allocated discontinuously from the rest of the object, then a warning
11859 should be generated upon reference to one of its storage place
11860 attributes.
11861 @end cartouche
11862 Followed. There are no such components in GNAT@.
11863
11864 @cindex Bit ordering
11865 @unnumberedsec 13.5.3(7-8): Bit Ordering
11866 @sp 1
11867 @cartouche
11868 The recommended level of support for the non-default bit ordering is:
11869 @end cartouche
11870 @sp 1
11871 @cartouche
11872 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
11873 should support the non-default bit ordering in addition to the default
11874 bit ordering.
11875 @end cartouche
11876 Followed. Word size does not equal storage size in this implementation.
11877 Thus non-default bit ordering is not supported.
11878
11879 @cindex @code{Address}, as private type
11880 @unnumberedsec 13.7(37): Address as Private
11881 @sp 1
11882 @cartouche
11883 @code{Address} should be of a private type.
11884 @end cartouche
11885 Followed.
11886
11887 @cindex Operations, on @code{Address}
11888 @cindex @code{Address}, operations of
11889 @unnumberedsec 13.7.1(16): Address Operations
11890 @sp 1
11891 @cartouche
11892 Operations in @code{System} and its children should reflect the target
11893 environment semantics as closely as is reasonable. For example, on most
11894 machines, it makes sense for address arithmetic to ``wrap around''.
11895 Operations that do not make sense should raise @code{Program_Error}.
11896 @end cartouche
11897 Followed. Address arithmetic is modular arithmetic that wraps around. No
11898 operation raises @code{Program_Error}, since all operations make sense.
11899
11900 @cindex Unchecked conversion
11901 @unnumberedsec 13.9(14-17): Unchecked Conversion
11902 @sp 1
11903 @cartouche
11904 The @code{Size} of an array object should not include its bounds; hence,
11905 the bounds should not be part of the converted data.
11906 @end cartouche
11907 Followed.
11908
11909 @sp 1
11910 @cartouche
11911 The implementation should not generate unnecessary run-time checks to
11912 ensure that the representation of @var{S} is a representation of the
11913 target type. It should take advantage of the permission to return by
11914 reference when possible. Restrictions on unchecked conversions should be
11915 avoided unless required by the target environment.
11916 @end cartouche
11917 Followed. There are no restrictions on unchecked conversion. A warning is
11918 generated if the source and target types do not have the same size since
11919 the semantics in this case may be target dependent.
11920
11921 @sp 1
11922 @cartouche
11923 The recommended level of support for unchecked conversions is:
11924 @end cartouche
11925 @sp 1
11926 @cartouche
11927 Unchecked conversions should be supported and should be reversible in
11928 the cases where this clause defines the result. To enable meaningful use
11929 of unchecked conversion, a contiguous representation should be used for
11930 elementary subtypes, for statically constrained array subtypes whose
11931 component subtype is one of the subtypes described in this paragraph,
11932 and for record subtypes without discriminants whose component subtypes
11933 are described in this paragraph.
11934 @end cartouche
11935 Followed.
11936
11937 @cindex Heap usage, implicit
11938 @unnumberedsec 13.11(23-25): Implicit Heap Usage
11939 @sp 1
11940 @cartouche
11941 An implementation should document any cases in which it dynamically
11942 allocates heap storage for a purpose other than the evaluation of an
11943 allocator.
11944 @end cartouche
11945 Followed, the only other points at which heap storage is dynamically
11946 allocated are as follows:
11947
11948 @itemize @bullet
11949 @item
11950 At initial elaboration time, to allocate dynamically sized global
11951 objects.
11952
11953 @item
11954 To allocate space for a task when a task is created.
11955
11956 @item
11957 To extend the secondary stack dynamically when needed. The secondary
11958 stack is used for returning variable length results.
11959 @end itemize
11960
11961 @sp 1
11962 @cartouche
11963 A default (implementation-provided) storage pool for an
11964 access-to-constant type should not have overhead to support deallocation of
11965 individual objects.
11966 @end cartouche
11967 Followed.
11968
11969 @sp 1
11970 @cartouche
11971 A storage pool for an anonymous access type should be created at the
11972 point of an allocator for the type, and be reclaimed when the designated
11973 object becomes inaccessible.
11974 @end cartouche
11975 Followed.
11976
11977 @cindex Unchecked deallocation
11978 @unnumberedsec 13.11.2(17): Unchecked De-allocation
11979 @sp 1
11980 @cartouche
11981 For a standard storage pool, @code{Free} should actually reclaim the
11982 storage.
11983 @end cartouche
11984 Followed.
11985
11986 @cindex Stream oriented attributes
11987 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
11988 @sp 1
11989 @cartouche
11990 If a stream element is the same size as a storage element, then the
11991 normal in-memory representation should be used by @code{Read} and
11992 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
11993 should use the smallest number of stream elements needed to represent
11994 all values in the base range of the scalar type.
11995 @end cartouche
11996
11997 Followed. By default, GNAT uses the interpretation suggested by AI-195,
11998 which specifies using the size of the first subtype.
11999 However, such an implementation is based on direct binary
12000 representations and is therefore target- and endianness-dependent.
12001 To address this issue, GNAT also supplies an alternate implementation
12002 of the stream attributes @code{Read} and @code{Write},
12003 which uses the target-independent XDR standard representation
12004 for scalar types.
12005 @cindex XDR representation
12006 @cindex @code{Read} attribute
12007 @cindex @code{Write} attribute
12008 @cindex Stream oriented attributes
12009 The XDR implementation is provided as an alternative body of the
12010 @code{System.Stream_Attributes} package, in the file
12011 @file{s-stratt-xdr.adb} in the GNAT library.
12012 There is no @file{s-stratt-xdr.ads} file.
12013 In order to install the XDR implementation, do the following:
12014 @enumerate
12015 @item Replace the default implementation of the
12016 @code{System.Stream_Attributes} package with the XDR implementation.
12017 For example on a Unix platform issue the commands:
12018 @smallexample
12019 $ mv s-stratt.adb s-stratt-default.adb
12020 $ mv s-stratt-xdr.adb s-stratt.adb
12021 @end smallexample
12022
12023 @item
12024 Rebuild the GNAT run-time library as documented in
12025 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
12026 @end enumerate
12027
12028 @unnumberedsec A.1(52): Names of Predefined Numeric Types
12029 @sp 1
12030 @cartouche
12031 If an implementation provides additional named predefined integer types,
12032 then the names should end with @samp{Integer} as in
12033 @samp{Long_Integer}. If an implementation provides additional named
12034 predefined floating point types, then the names should end with
12035 @samp{Float} as in @samp{Long_Float}.
12036 @end cartouche
12037 Followed.
12038
12039 @findex Ada.Characters.Handling
12040 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
12041 @sp 1
12042 @cartouche
12043 If an implementation provides a localized definition of @code{Character}
12044 or @code{Wide_Character}, then the effects of the subprograms in
12045 @code{Characters.Handling} should reflect the localizations. See also
12046 3.5.2.
12047 @end cartouche
12048 Followed. GNAT provides no such localized definitions.
12049
12050 @cindex Bounded-length strings
12051 @unnumberedsec A.4.4(106): Bounded-Length String Handling
12052 @sp 1
12053 @cartouche
12054 Bounded string objects should not be implemented by implicit pointers
12055 and dynamic allocation.
12056 @end cartouche
12057 Followed. No implicit pointers or dynamic allocation are used.
12058
12059 @cindex Random number generation
12060 @unnumberedsec A.5.2(46-47): Random Number Generation
12061 @sp 1
12062 @cartouche
12063 Any storage associated with an object of type @code{Generator} should be
12064 reclaimed on exit from the scope of the object.
12065 @end cartouche
12066 Followed.
12067
12068 @sp 1
12069 @cartouche
12070 If the generator period is sufficiently long in relation to the number
12071 of distinct initiator values, then each possible value of
12072 @code{Initiator} passed to @code{Reset} should initiate a sequence of
12073 random numbers that does not, in a practical sense, overlap the sequence
12074 initiated by any other value. If this is not possible, then the mapping
12075 between initiator values and generator states should be a rapidly
12076 varying function of the initiator value.
12077 @end cartouche
12078 Followed. The generator period is sufficiently long for the first
12079 condition here to hold true.
12080
12081 @findex Get_Immediate
12082 @unnumberedsec A.10.7(23): @code{Get_Immediate}
12083 @sp 1
12084 @cartouche
12085 The @code{Get_Immediate} procedures should be implemented with
12086 unbuffered input. For a device such as a keyboard, input should be
12087 @dfn{available} if a key has already been typed, whereas for a disk
12088 file, input should always be available except at end of file. For a file
12089 associated with a keyboard-like device, any line-editing features of the
12090 underlying operating system should be disabled during the execution of
12091 @code{Get_Immediate}.
12092 @end cartouche
12093 Followed on all targets except VxWorks. For VxWorks, there is no way to
12094 provide this functionality that does not result in the input buffer being
12095 flushed before the @code{Get_Immediate} call. A special unit
12096 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
12097 this functionality.
12098
12099 @findex Export
12100 @unnumberedsec B.1(39-41): Pragma @code{Export}
12101 @sp 1
12102 @cartouche
12103 If an implementation supports pragma @code{Export} to a given language,
12104 then it should also allow the main subprogram to be written in that
12105 language. It should support some mechanism for invoking the elaboration
12106 of the Ada library units included in the system, and for invoking the
12107 finalization of the environment task. On typical systems, the
12108 recommended mechanism is to provide two subprograms whose link names are
12109 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
12110 elaboration code for library units. @code{adafinal} should contain the
12111 finalization code. These subprograms should have no effect the second
12112 and subsequent time they are called.
12113 @end cartouche
12114 Followed.
12115
12116 @sp 1
12117 @cartouche
12118 Automatic elaboration of pre-elaborated packages should be
12119 provided when pragma @code{Export} is supported.
12120 @end cartouche
12121 Followed when the main program is in Ada. If the main program is in a
12122 foreign language, then
12123 @code{adainit} must be called to elaborate pre-elaborated
12124 packages.
12125
12126 @sp 1
12127 @cartouche
12128 For each supported convention @var{L} other than @code{Intrinsic}, an
12129 implementation should support @code{Import} and @code{Export} pragmas
12130 for objects of @var{L}-compatible types and for subprograms, and pragma
12131 @code{Convention} for @var{L}-eligible types and for subprograms,
12132 presuming the other language has corresponding features. Pragma
12133 @code{Convention} need not be supported for scalar types.
12134 @end cartouche
12135 Followed.
12136
12137 @cindex Package @code{Interfaces}
12138 @findex Interfaces
12139 @unnumberedsec B.2(12-13): Package @code{Interfaces}
12140 @sp 1
12141 @cartouche
12142 For each implementation-defined convention identifier, there should be a
12143 child package of package Interfaces with the corresponding name. This
12144 package should contain any declarations that would be useful for
12145 interfacing to the language (implementation) represented by the
12146 convention. Any declarations useful for interfacing to any language on
12147 the given hardware architecture should be provided directly in
12148 @code{Interfaces}.
12149 @end cartouche
12150 Followed.
12151
12152 @sp 1
12153 @cartouche
12154 An implementation supporting an interface to C, COBOL, or Fortran should
12155 provide the corresponding package or packages described in the following
12156 clauses.
12157 @end cartouche
12158 Followed. GNAT provides all the packages described in this section.
12159
12160 @cindex C, interfacing with
12161 @unnumberedsec B.3(63-71): Interfacing with C
12162 @sp 1
12163 @cartouche
12164 An implementation should support the following interface correspondences
12165 between Ada and C@.
12166 @end cartouche
12167 Followed.
12168
12169 @sp 1
12170 @cartouche
12171 An Ada procedure corresponds to a void-returning C function.
12172 @end cartouche
12173 Followed.
12174
12175 @sp 1
12176 @cartouche
12177 An Ada function corresponds to a non-void C function.
12178 @end cartouche
12179 Followed.
12180
12181 @sp 1
12182 @cartouche
12183 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
12184 function.
12185 @end cartouche
12186 Followed.
12187
12188 @sp 1
12189 @cartouche
12190 An Ada @code{in} parameter of an access-to-object type with designated
12191 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
12192 where @var{t} is the C type corresponding to the Ada type @var{T}.
12193 @end cartouche
12194 Followed.
12195
12196 @sp 1
12197 @cartouche
12198 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
12199 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
12200 argument to a C function, where @var{t} is the C type corresponding to
12201 the Ada type @var{T}. In the case of an elementary @code{out} or
12202 @code{in out} parameter, a pointer to a temporary copy is used to
12203 preserve by-copy semantics.
12204 @end cartouche
12205 Followed.
12206
12207 @sp 1
12208 @cartouche
12209 An Ada parameter of a record type @var{T}, of any mode, is passed as a
12210 @code{@var{t}*} argument to a C function, where @var{t} is the C
12211 structure corresponding to the Ada type @var{T}.
12212 @end cartouche
12213 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
12214 pragma, or Convention, or by explicitly specifying the mechanism for a given
12215 call using an extended import or export pragma.
12216
12217 @sp 1
12218 @cartouche
12219 An Ada parameter of an array type with component type @var{T}, of any
12220 mode, is passed as a @code{@var{t}*} argument to a C function, where
12221 @var{t} is the C type corresponding to the Ada type @var{T}.
12222 @end cartouche
12223 Followed.
12224
12225 @sp 1
12226 @cartouche
12227 An Ada parameter of an access-to-subprogram type is passed as a pointer
12228 to a C function whose prototype corresponds to the designated
12229 subprogram's specification.
12230 @end cartouche
12231 Followed.
12232
12233 @cindex COBOL, interfacing with
12234 @unnumberedsec B.4(95-98): Interfacing with COBOL
12235 @sp 1
12236 @cartouche
12237 An Ada implementation should support the following interface
12238 correspondences between Ada and COBOL@.
12239 @end cartouche
12240 Followed.
12241
12242 @sp 1
12243 @cartouche
12244 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
12245 the COBOL type corresponding to @var{T}.
12246 @end cartouche
12247 Followed.
12248
12249 @sp 1
12250 @cartouche
12251 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
12252 the corresponding COBOL type.
12253 @end cartouche
12254 Followed.
12255
12256 @sp 1
12257 @cartouche
12258 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
12259 COBOL type corresponding to the Ada parameter type; for scalars, a local
12260 copy is used if necessary to ensure by-copy semantics.
12261 @end cartouche
12262 Followed.
12263
12264 @cindex Fortran, interfacing with
12265 @unnumberedsec B.5(22-26): Interfacing with Fortran
12266 @sp 1
12267 @cartouche
12268 An Ada implementation should support the following interface
12269 correspondences between Ada and Fortran:
12270 @end cartouche
12271 Followed.
12272
12273 @sp 1
12274 @cartouche
12275 An Ada procedure corresponds to a Fortran subroutine.
12276 @end cartouche
12277 Followed.
12278
12279 @sp 1
12280 @cartouche
12281 An Ada function corresponds to a Fortran function.
12282 @end cartouche
12283 Followed.
12284
12285 @sp 1
12286 @cartouche
12287 An Ada parameter of an elementary, array, or record type @var{T} is
12288 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
12289 the Fortran type corresponding to the Ada type @var{T}, and where the
12290 INTENT attribute of the corresponding dummy argument matches the Ada
12291 formal parameter mode; the Fortran implementation's parameter passing
12292 conventions are used. For elementary types, a local copy is used if
12293 necessary to ensure by-copy semantics.
12294 @end cartouche
12295 Followed.
12296
12297 @sp 1
12298 @cartouche
12299 An Ada parameter of an access-to-subprogram type is passed as a
12300 reference to a Fortran procedure whose interface corresponds to the
12301 designated subprogram's specification.
12302 @end cartouche
12303 Followed.
12304
12305 @cindex Machine operations
12306 @unnumberedsec C.1(3-5): Access to Machine Operations
12307 @sp 1
12308 @cartouche
12309 The machine code or intrinsic support should allow access to all
12310 operations normally available to assembly language programmers for the
12311 target environment, including privileged instructions, if any.
12312 @end cartouche
12313 Followed.
12314
12315 @sp 1
12316 @cartouche
12317 The interfacing pragmas (see Annex B) should support interface to
12318 assembler; the default assembler should be associated with the
12319 convention identifier @code{Assembler}.
12320 @end cartouche
12321 Followed.
12322
12323 @sp 1
12324 @cartouche
12325 If an entity is exported to assembly language, then the implementation
12326 should allocate it at an addressable location, and should ensure that it
12327 is retained by the linking process, even if not otherwise referenced
12328 from the Ada code. The implementation should assume that any call to a
12329 machine code or assembler subprogram is allowed to read or update every
12330 object that is specified as exported.
12331 @end cartouche
12332 Followed.
12333
12334 @unnumberedsec C.1(10-16): Access to Machine Operations
12335 @sp 1
12336 @cartouche
12337 The implementation should ensure that little or no overhead is
12338 associated with calling intrinsic and machine-code subprograms.
12339 @end cartouche
12340 Followed for both intrinsics and machine-code subprograms.
12341
12342 @sp 1
12343 @cartouche
12344 It is recommended that intrinsic subprograms be provided for convenient
12345 access to any machine operations that provide special capabilities or
12346 efficiency and that are not otherwise available through the language
12347 constructs.
12348 @end cartouche
12349 Followed. A full set of machine operation intrinsic subprograms is provided.
12350
12351 @sp 1
12352 @cartouche
12353 Atomic read-modify-write operations---e.g.@:, test and set, compare and
12354 swap, decrement and test, enqueue/dequeue.
12355 @end cartouche
12356 Followed on any target supporting such operations.
12357
12358 @sp 1
12359 @cartouche
12360 Standard numeric functions---e.g.@:, sin, log.
12361 @end cartouche
12362 Followed on any target supporting such operations.
12363
12364 @sp 1
12365 @cartouche
12366 String manipulation operations---e.g.@:, translate and test.
12367 @end cartouche
12368 Followed on any target supporting such operations.
12369
12370 @sp 1
12371 @cartouche
12372 Vector operations---e.g.@:, compare vector against thresholds.
12373 @end cartouche
12374 Followed on any target supporting such operations.
12375
12376 @sp 1
12377 @cartouche
12378 Direct operations on I/O ports.
12379 @end cartouche
12380 Followed on any target supporting such operations.
12381
12382 @cindex Interrupt support
12383 @unnumberedsec C.3(28): Interrupt Support
12384 @sp 1
12385 @cartouche
12386 If the @code{Ceiling_Locking} policy is not in effect, the
12387 implementation should provide means for the application to specify which
12388 interrupts are to be blocked during protected actions, if the underlying
12389 system allows for a finer-grain control of interrupt blocking.
12390 @end cartouche
12391 Followed. The underlying system does not allow for finer-grain control
12392 of interrupt blocking.
12393
12394 @cindex Protected procedure handlers
12395 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
12396 @sp 1
12397 @cartouche
12398 Whenever possible, the implementation should allow interrupt handlers to
12399 be called directly by the hardware.
12400 @end cartouche
12401 Followed on any target where the underlying operating system permits
12402 such direct calls.
12403
12404 @sp 1
12405 @cartouche
12406 Whenever practical, violations of any
12407 implementation-defined restrictions should be detected before run time.
12408 @end cartouche
12409 Followed. Compile time warnings are given when possible.
12410
12411 @cindex Package @code{Interrupts}
12412 @findex Interrupts
12413 @unnumberedsec C.3.2(25): Package @code{Interrupts}
12414
12415 @sp 1
12416 @cartouche
12417 If implementation-defined forms of interrupt handler procedures are
12418 supported, such as protected procedures with parameters, then for each
12419 such form of a handler, a type analogous to @code{Parameterless_Handler}
12420 should be specified in a child package of @code{Interrupts}, with the
12421 same operations as in the predefined package Interrupts.
12422 @end cartouche
12423 Followed.
12424
12425 @cindex Pre-elaboration requirements
12426 @unnumberedsec C.4(14): Pre-elaboration Requirements
12427 @sp 1
12428 @cartouche
12429 It is recommended that pre-elaborated packages be implemented in such a
12430 way that there should be little or no code executed at run time for the
12431 elaboration of entities not already covered by the Implementation
12432 Requirements.
12433 @end cartouche
12434 Followed. Executable code is generated in some cases, e.g.@: loops
12435 to initialize large arrays.
12436
12437 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
12438 @sp 1
12439 @cartouche
12440 If the pragma applies to an entity, then the implementation should
12441 reduce the amount of storage used for storing names associated with that
12442 entity.
12443 @end cartouche
12444 Followed.
12445
12446 @cindex Package @code{Task_Attributes}
12447 @findex Task_Attributes
12448 @unnumberedsec C.7.2(30): The Package Task_Attributes
12449 @sp 1
12450 @cartouche
12451 Some implementations are targeted to domains in which memory use at run
12452 time must be completely deterministic. For such implementations, it is
12453 recommended that the storage for task attributes will be pre-allocated
12454 statically and not from the heap. This can be accomplished by either
12455 placing restrictions on the number and the size of the task's
12456 attributes, or by using the pre-allocated storage for the first @var{N}
12457 attribute objects, and the heap for the others. In the latter case,
12458 @var{N} should be documented.
12459 @end cartouche
12460 Not followed. This implementation is not targeted to such a domain.
12461
12462 @cindex Locking Policies
12463 @unnumberedsec D.3(17): Locking Policies
12464
12465 @sp 1
12466 @cartouche
12467 The implementation should use names that end with @samp{_Locking} for
12468 locking policies defined by the implementation.
12469 @end cartouche
12470 Followed. Two implementation-defined locking policies are defined,
12471 whose names (@code{Inheritance_Locking} and
12472 @code{Concurrent_Readers_Locking}) follow this suggestion.
12473
12474 @cindex Entry queuing policies
12475 @unnumberedsec D.4(16): Entry Queuing Policies
12476 @sp 1
12477 @cartouche
12478 Names that end with @samp{_Queuing} should be used
12479 for all implementation-defined queuing policies.
12480 @end cartouche
12481 Followed. No such implementation-defined queuing policies exist.
12482
12483 @cindex Preemptive abort
12484 @unnumberedsec D.6(9-10): Preemptive Abort
12485 @sp 1
12486 @cartouche
12487 Even though the @code{abort_statement} is included in the list of
12488 potentially blocking operations (see 9.5.1), it is recommended that this
12489 statement be implemented in a way that never requires the task executing
12490 the @code{abort_statement} to block.
12491 @end cartouche
12492 Followed.
12493
12494 @sp 1
12495 @cartouche
12496 On a multi-processor, the delay associated with aborting a task on
12497 another processor should be bounded; the implementation should use
12498 periodic polling, if necessary, to achieve this.
12499 @end cartouche
12500 Followed.
12501
12502 @cindex Tasking restrictions
12503 @unnumberedsec D.7(21): Tasking Restrictions
12504 @sp 1
12505 @cartouche
12506 When feasible, the implementation should take advantage of the specified
12507 restrictions to produce a more efficient implementation.
12508 @end cartouche
12509 GNAT currently takes advantage of these restrictions by providing an optimized
12510 run time when the Ravenscar profile and the GNAT restricted run time set
12511 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
12512 pragma @code{Profile (Restricted)} for more details.
12513
12514 @cindex Time, monotonic
12515 @unnumberedsec D.8(47-49): Monotonic Time
12516 @sp 1
12517 @cartouche
12518 When appropriate, implementations should provide configuration
12519 mechanisms to change the value of @code{Tick}.
12520 @end cartouche
12521 Such configuration mechanisms are not appropriate to this implementation
12522 and are thus not supported.
12523
12524 @sp 1
12525 @cartouche
12526 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
12527 be implemented as transformations of the same time base.
12528 @end cartouche
12529 Followed.
12530
12531 @sp 1
12532 @cartouche
12533 It is recommended that the @dfn{best} time base which exists in
12534 the underlying system be available to the application through
12535 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
12536 @end cartouche
12537 Followed.
12538
12539 @cindex Partition communication subsystem
12540 @cindex PCS
12541 @unnumberedsec E.5(28-29): Partition Communication Subsystem
12542 @sp 1
12543 @cartouche
12544 Whenever possible, the PCS on the called partition should allow for
12545 multiple tasks to call the RPC-receiver with different messages and
12546 should allow them to block until the corresponding subprogram body
12547 returns.
12548 @end cartouche
12549 Followed by GLADE, a separately supplied PCS that can be used with
12550 GNAT.
12551
12552 @sp 1
12553 @cartouche
12554 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
12555 should raise @code{Storage_Error} if it runs out of space trying to
12556 write the @code{Item} into the stream.
12557 @end cartouche
12558 Followed by GLADE, a separately supplied PCS that can be used with
12559 GNAT@.
12560
12561 @cindex COBOL support
12562 @unnumberedsec F(7): COBOL Support
12563 @sp 1
12564 @cartouche
12565 If COBOL (respectively, C) is widely supported in the target
12566 environment, implementations supporting the Information Systems Annex
12567 should provide the child package @code{Interfaces.COBOL} (respectively,
12568 @code{Interfaces.C}) specified in Annex B and should support a
12569 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
12570 pragmas (see Annex B), thus allowing Ada programs to interface with
12571 programs written in that language.
12572 @end cartouche
12573 Followed.
12574
12575 @cindex Decimal radix support
12576 @unnumberedsec F.1(2): Decimal Radix Support
12577 @sp 1
12578 @cartouche
12579 Packed decimal should be used as the internal representation for objects
12580 of subtype @var{S} when @var{S}'Machine_Radix = 10.
12581 @end cartouche
12582 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
12583 representations.
12584
12585 @cindex Numerics
12586 @unnumberedsec G: Numerics
12587 @sp 2
12588 @cartouche
12589 If Fortran (respectively, C) is widely supported in the target
12590 environment, implementations supporting the Numerics Annex
12591 should provide the child package @code{Interfaces.Fortran} (respectively,
12592 @code{Interfaces.C}) specified in Annex B and should support a
12593 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
12594 pragmas (see Annex B), thus allowing Ada programs to interface with
12595 programs written in that language.
12596 @end cartouche
12597 Followed.
12598
12599 @cindex Complex types
12600 @unnumberedsec G.1.1(56-58): Complex Types
12601 @sp 2
12602 @cartouche
12603 Because the usual mathematical meaning of multiplication of a complex
12604 operand and a real operand is that of the scaling of both components of
12605 the former by the latter, an implementation should not perform this
12606 operation by first promoting the real operand to complex type and then
12607 performing a full complex multiplication. In systems that, in the
12608 future, support an Ada binding to IEC 559:1989, the latter technique
12609 will not generate the required result when one of the components of the
12610 complex operand is infinite. (Explicit multiplication of the infinite
12611 component by the zero component obtained during promotion yields a NaN
12612 that propagates into the final result.) Analogous advice applies in the
12613 case of multiplication of a complex operand and a pure-imaginary
12614 operand, and in the case of division of a complex operand by a real or
12615 pure-imaginary operand.
12616 @end cartouche
12617 Not followed.
12618
12619 @sp 1
12620 @cartouche
12621 Similarly, because the usual mathematical meaning of addition of a
12622 complex operand and a real operand is that the imaginary operand remains
12623 unchanged, an implementation should not perform this operation by first
12624 promoting the real operand to complex type and then performing a full
12625 complex addition. In implementations in which the @code{Signed_Zeros}
12626 attribute of the component type is @code{True} (and which therefore
12627 conform to IEC 559:1989 in regard to the handling of the sign of zero in
12628 predefined arithmetic operations), the latter technique will not
12629 generate the required result when the imaginary component of the complex
12630 operand is a negatively signed zero. (Explicit addition of the negative
12631 zero to the zero obtained during promotion yields a positive zero.)
12632 Analogous advice applies in the case of addition of a complex operand
12633 and a pure-imaginary operand, and in the case of subtraction of a
12634 complex operand and a real or pure-imaginary operand.
12635 @end cartouche
12636 Not followed.
12637
12638 @sp 1
12639 @cartouche
12640 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
12641 attempt to provide a rational treatment of the signs of zero results and
12642 result components. As one example, the result of the @code{Argument}
12643 function should have the sign of the imaginary component of the
12644 parameter @code{X} when the point represented by that parameter lies on
12645 the positive real axis; as another, the sign of the imaginary component
12646 of the @code{Compose_From_Polar} function should be the same as
12647 (respectively, the opposite of) that of the @code{Argument} parameter when that
12648 parameter has a value of zero and the @code{Modulus} parameter has a
12649 nonnegative (respectively, negative) value.
12650 @end cartouche
12651 Followed.
12652
12653 @cindex Complex elementary functions
12654 @unnumberedsec G.1.2(49): Complex Elementary Functions
12655 @sp 1
12656 @cartouche
12657 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
12658 @code{True} should attempt to provide a rational treatment of the signs
12659 of zero results and result components. For example, many of the complex
12660 elementary functions have components that are odd functions of one of
12661 the parameter components; in these cases, the result component should
12662 have the sign of the parameter component at the origin. Other complex
12663 elementary functions have zero components whose sign is opposite that of
12664 a parameter component at the origin, or is always positive or always
12665 negative.
12666 @end cartouche
12667 Followed.
12668
12669 @cindex Accuracy requirements
12670 @unnumberedsec G.2.4(19): Accuracy Requirements
12671 @sp 1
12672 @cartouche
12673 The versions of the forward trigonometric functions without a
12674 @code{Cycle} parameter should not be implemented by calling the
12675 corresponding version with a @code{Cycle} parameter of
12676 @code{2.0*Numerics.Pi}, since this will not provide the required
12677 accuracy in some portions of the domain. For the same reason, the
12678 version of @code{Log} without a @code{Base} parameter should not be
12679 implemented by calling the corresponding version with a @code{Base}
12680 parameter of @code{Numerics.e}.
12681 @end cartouche
12682 Followed.
12683
12684 @cindex Complex arithmetic accuracy
12685 @cindex Accuracy, complex arithmetic
12686 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
12687
12688 @sp 1
12689 @cartouche
12690 The version of the @code{Compose_From_Polar} function without a
12691 @code{Cycle} parameter should not be implemented by calling the
12692 corresponding version with a @code{Cycle} parameter of
12693 @code{2.0*Numerics.Pi}, since this will not provide the required
12694 accuracy in some portions of the domain.
12695 @end cartouche
12696 Followed.
12697
12698 @cindex Sequential elaboration policy
12699 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
12700
12701 @sp 1
12702 @cartouche
12703 If the partition elaboration policy is @code{Sequential} and the
12704 Environment task becomes permanently blocked during elaboration then the
12705 partition is deadlocked and it is recommended that the partition be
12706 immediately terminated.
12707 @end cartouche
12708 Not followed.
12709
12710 @c -----------------------------------------
12711 @node Implementation Defined Characteristics
12712 @chapter Implementation Defined Characteristics
12713
12714 @noindent
12715 In addition to the implementation dependent pragmas and attributes, and the
12716 implementation advice, there are a number of other Ada features that are
12717 potentially implementation dependent and are designated as
12718 implementation-defined. These are mentioned throughout the Ada Reference
12719 Manual, and are summarized in Annex M@.
12720
12721 A requirement for conforming Ada compilers is that they provide
12722 documentation describing how the implementation deals with each of these
12723 issues. In this chapter you will find each point in Annex M listed,
12724 followed by a description of how GNAT
12725 handles the implementation dependence.
12726
12727 You can use this chapter as a guide to minimizing implementation
12728 dependent features in your programs if portability to other compilers
12729 and other operating systems is an important consideration. The numbers
12730 in each entry below correspond to the paragraph numbers in the Ada
12731 Reference Manual.
12732
12733
12734 @itemize @bullet
12735 @sp 1
12736 @item
12737 @cartouche
12738 @noindent
12739 Whether or not each recommendation given in Implementation
12740 Advice is followed. See 1.1.2(37).
12741 @end cartouche
12742 @noindent
12743 @xref{Implementation Advice}.
12744
12745
12746 @sp 1
12747 @item
12748 @cartouche
12749 @noindent
12750 Capacity limitations of the implementation. See 1.1.3(3).
12751 @end cartouche
12752 @noindent
12753 The complexity of programs that can be processed is limited only by the
12754 total amount of available virtual memory, and disk space for the
12755 generated object files.
12756
12757
12758 @sp 1
12759 @item
12760 @cartouche
12761 @noindent
12762 Variations from the standard that are impractical to avoid
12763 given the implementation's execution environment. See 1.1.3(6).
12764 @end cartouche
12765 @noindent
12766 There are no variations from the standard.
12767
12768
12769 @sp 1
12770 @item
12771 @cartouche
12772 @noindent
12773 Which @code{code_statement}s cause external
12774 interactions. See 1.1.3(10).
12775 @end cartouche
12776 @noindent
12777 Any @code{code_statement} can potentially cause external interactions.
12778
12779 @sp 1
12780 @item
12781 @cartouche
12782 @noindent
12783 The coded representation for the text of an Ada
12784 program. See 2.1(4).
12785 @end cartouche
12786 @noindent
12787 See separate section on source representation.
12788
12789
12790 @sp 1
12791 @item
12792 @cartouche
12793 @noindent
12794 The control functions allowed in comments. See 2.1(14).
12795 @end cartouche
12796 @noindent
12797 See separate section on source representation.
12798
12799 @sp 1
12800 @item
12801 @cartouche
12802 @noindent
12803 The representation for an end of line. See 2.2(2).
12804 @end cartouche
12805 @noindent
12806 See separate section on source representation.
12807
12808 @sp 1
12809 @item
12810 @cartouche
12811 @noindent
12812 Maximum supported line length and lexical element
12813 length. See 2.2(15).
12814 @end cartouche
12815 @noindent
12816 The maximum line length is 255 characters and the maximum length of
12817 a lexical element is also 255 characters. This is the default setting
12818 if not overridden by the use of compiler switch @option{-gnaty} (which
12819 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
12820 line length to be specified to be any value up to 32767. The maximum
12821 length of a lexical element is the same as the maximum line length.
12822
12823 @sp 1
12824 @item
12825 @cartouche
12826 @noindent
12827 Implementation defined pragmas. See 2.8(14).
12828 @end cartouche
12829 @noindent
12830
12831 @xref{Implementation Defined Pragmas}.
12832
12833 @sp 1
12834 @item
12835 @cartouche
12836 @noindent
12837 Effect of pragma @code{Optimize}. See 2.8(27).
12838 @end cartouche
12839 @noindent
12840 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
12841 parameter, checks that the optimization flag is set, and aborts if it is
12842 not.
12843
12844 @sp 1
12845 @item
12846 @cartouche
12847 @noindent
12848 The sequence of characters of the value returned by
12849 @code{@var{S}'Image} when some of the graphic characters of
12850 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
12851 3.5(37).
12852 @end cartouche
12853 @noindent
12854 The sequence of characters is as defined by the wide character encoding
12855 method used for the source. See section on source representation for
12856 further details.
12857
12858 @sp 1
12859 @item
12860 @cartouche
12861 @noindent
12862 The predefined integer types declared in
12863 @code{Standard}. See 3.5.4(25).
12864 @end cartouche
12865 @noindent
12866 @table @code
12867 @item Short_Short_Integer
12868 8 bit signed
12869 @item Short_Integer
12870 (Short) 16 bit signed
12871 @item Integer
12872 32 bit signed
12873 @item Long_Integer
12874 64 bit signed (on most 64 bit targets, depending on the C definition of long).
12875 32 bit signed (all other targets)
12876 @item Long_Long_Integer
12877 64 bit signed
12878 @end table
12879
12880 @sp 1
12881 @item
12882 @cartouche
12883 @noindent
12884 Any nonstandard integer types and the operators defined
12885 for them. See 3.5.4(26).
12886 @end cartouche
12887 @noindent
12888 There are no nonstandard integer types.
12889
12890 @sp 1
12891 @item
12892 @cartouche
12893 @noindent
12894 Any nonstandard real types and the operators defined for
12895 them. See 3.5.6(8).
12896 @end cartouche
12897 @noindent
12898 There are no nonstandard real types.
12899
12900 @sp 1
12901 @item
12902 @cartouche
12903 @noindent
12904 What combinations of requested decimal precision and range
12905 are supported for floating point types. See 3.5.7(7).
12906 @end cartouche
12907 @noindent
12908 The precision and range is as defined by the IEEE standard.
12909
12910 @sp 1
12911 @item
12912 @cartouche
12913 @noindent
12914 The predefined floating point types declared in
12915 @code{Standard}. See 3.5.7(16).
12916 @end cartouche
12917 @noindent
12918 @table @code
12919 @item Short_Float
12920 32 bit IEEE short
12921 @item Float
12922 (Short) 32 bit IEEE short
12923 @item Long_Float
12924 64 bit IEEE long
12925 @item Long_Long_Float
12926 64 bit IEEE long (80 bit IEEE long on x86 processors)
12927 @end table
12928
12929 @sp 1
12930 @item
12931 @cartouche
12932 @noindent
12933 The small of an ordinary fixed point type. See 3.5.9(8).
12934 @end cartouche
12935 @noindent
12936 @code{Fine_Delta} is 2**(@minus{}63)
12937
12938 @sp 1
12939 @item
12940 @cartouche
12941 @noindent
12942 What combinations of small, range, and digits are
12943 supported for fixed point types. See 3.5.9(10).
12944 @end cartouche
12945 @noindent
12946 Any combinations are permitted that do not result in a small less than
12947 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
12948 If the mantissa is larger than 53 bits on machines where Long_Long_Float
12949 is 64 bits (true of all architectures except ia32), then the output from
12950 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
12951 is because floating-point conversions are used to convert fixed point.
12952
12953 @sp 1
12954 @item
12955 @cartouche
12956 @noindent
12957 The result of @code{Tags.Expanded_Name} for types declared
12958 within an unnamed @code{block_statement}. See 3.9(10).
12959 @end cartouche
12960 @noindent
12961 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
12962 decimal integer are allocated.
12963
12964 @sp 1
12965 @item
12966 @cartouche
12967 @noindent
12968 Implementation-defined attributes. See 4.1.4(12).
12969 @end cartouche
12970 @noindent
12971 @xref{Implementation Defined Attributes}.
12972
12973 @sp 1
12974 @item
12975 @cartouche
12976 @noindent
12977 Any implementation-defined time types. See 9.6(6).
12978 @end cartouche
12979 @noindent
12980 There are no implementation-defined time types.
12981
12982 @sp 1
12983 @item
12984 @cartouche
12985 @noindent
12986 The time base associated with relative delays.
12987 @end cartouche
12988 @noindent
12989 See 9.6(20). The time base used is that provided by the C library
12990 function @code{gettimeofday}.
12991
12992 @sp 1
12993 @item
12994 @cartouche
12995 @noindent
12996 The time base of the type @code{Calendar.Time}. See
12997 9.6(23).
12998 @end cartouche
12999 @noindent
13000 The time base used is that provided by the C library function
13001 @code{gettimeofday}.
13002
13003 @sp 1
13004 @item
13005 @cartouche
13006 @noindent
13007 The time zone used for package @code{Calendar}
13008 operations. See 9.6(24).
13009 @end cartouche
13010 @noindent
13011 The time zone used by package @code{Calendar} is the current system time zone
13012 setting for local time, as accessed by the C library function
13013 @code{localtime}.
13014
13015 @sp 1
13016 @item
13017 @cartouche
13018 @noindent
13019 Any limit on @code{delay_until_statements} of
13020 @code{select_statements}. See 9.6(29).
13021 @end cartouche
13022 @noindent
13023 There are no such limits.
13024
13025 @sp 1
13026 @item
13027 @cartouche
13028 @noindent
13029 Whether or not two non-overlapping parts of a composite
13030 object are independently addressable, in the case where packing, record
13031 layout, or @code{Component_Size} is specified for the object. See
13032 9.10(1).
13033 @end cartouche
13034 @noindent
13035 Separate components are independently addressable if they do not share
13036 overlapping storage units.
13037
13038 @sp 1
13039 @item
13040 @cartouche
13041 @noindent
13042 The representation for a compilation. See 10.1(2).
13043 @end cartouche
13044 @noindent
13045 A compilation is represented by a sequence of files presented to the
13046 compiler in a single invocation of the @command{gcc} command.
13047
13048 @sp 1
13049 @item
13050 @cartouche
13051 @noindent
13052 Any restrictions on compilations that contain multiple
13053 compilation_units. See 10.1(4).
13054 @end cartouche
13055 @noindent
13056 No single file can contain more than one compilation unit, but any
13057 sequence of files can be presented to the compiler as a single
13058 compilation.
13059
13060 @sp 1
13061 @item
13062 @cartouche
13063 @noindent
13064 The mechanisms for creating an environment and for adding
13065 and replacing compilation units. See 10.1.4(3).
13066 @end cartouche
13067 @noindent
13068 See separate section on compilation model.
13069
13070 @sp 1
13071 @item
13072 @cartouche
13073 @noindent
13074 The manner of explicitly assigning library units to a
13075 partition. See 10.2(2).
13076 @end cartouche
13077 @noindent
13078 If a unit contains an Ada main program, then the Ada units for the partition
13079 are determined by recursive application of the rules in the Ada Reference
13080 Manual section 10.2(2-6). In other words, the Ada units will be those that
13081 are needed by the main program, and then this definition of need is applied
13082 recursively to those units, and the partition contains the transitive
13083 closure determined by this relationship. In short, all the necessary units
13084 are included, with no need to explicitly specify the list. If additional
13085 units are required, e.g.@: by foreign language units, then all units must be
13086 mentioned in the context clause of one of the needed Ada units.
13087
13088 If the partition contains no main program, or if the main program is in
13089 a language other than Ada, then GNAT
13090 provides the binder options @option{-z} and @option{-n} respectively, and in
13091 this case a list of units can be explicitly supplied to the binder for
13092 inclusion in the partition (all units needed by these units will also
13093 be included automatically). For full details on the use of these
13094 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
13095 @value{EDITION} User's Guide}.
13096
13097 @sp 1
13098 @item
13099 @cartouche
13100 @noindent
13101 The implementation-defined means, if any, of specifying
13102 which compilation units are needed by a given compilation unit. See
13103 10.2(2).
13104 @end cartouche
13105 @noindent
13106 The units needed by a given compilation unit are as defined in
13107 the Ada Reference Manual section 10.2(2-6). There are no
13108 implementation-defined pragmas or other implementation-defined
13109 means for specifying needed units.
13110
13111 @sp 1
13112 @item
13113 @cartouche
13114 @noindent
13115 The manner of designating the main subprogram of a
13116 partition. See 10.2(7).
13117 @end cartouche
13118 @noindent
13119 The main program is designated by providing the name of the
13120 corresponding @file{ALI} file as the input parameter to the binder.
13121
13122 @sp 1
13123 @item
13124 @cartouche
13125 @noindent
13126 The order of elaboration of @code{library_items}. See
13127 10.2(18).
13128 @end cartouche
13129 @noindent
13130 The first constraint on ordering is that it meets the requirements of
13131 Chapter 10 of the Ada Reference Manual. This still leaves some
13132 implementation dependent choices, which are resolved by first
13133 elaborating bodies as early as possible (i.e., in preference to specs
13134 where there is a choice), and second by evaluating the immediate with
13135 clauses of a unit to determine the probably best choice, and
13136 third by elaborating in alphabetical order of unit names
13137 where a choice still remains.
13138
13139 @sp 1
13140 @item
13141 @cartouche
13142 @noindent
13143 Parameter passing and function return for the main
13144 subprogram. See 10.2(21).
13145 @end cartouche
13146 @noindent
13147 The main program has no parameters. It may be a procedure, or a function
13148 returning an integer type. In the latter case, the returned integer
13149 value is the return code of the program (overriding any value that
13150 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
13151
13152 @sp 1
13153 @item
13154 @cartouche
13155 @noindent
13156 The mechanisms for building and running partitions. See
13157 10.2(24).
13158 @end cartouche
13159 @noindent
13160 GNAT itself supports programs with only a single partition. The GNATDIST
13161 tool provided with the GLADE package (which also includes an implementation
13162 of the PCS) provides a completely flexible method for building and running
13163 programs consisting of multiple partitions. See the separate GLADE manual
13164 for details.
13165
13166 @sp 1
13167 @item
13168 @cartouche
13169 @noindent
13170 The details of program execution, including program
13171 termination. See 10.2(25).
13172 @end cartouche
13173 @noindent
13174 See separate section on compilation model.
13175
13176 @sp 1
13177 @item
13178 @cartouche
13179 @noindent
13180 The semantics of any non-active partitions supported by the
13181 implementation. See 10.2(28).
13182 @end cartouche
13183 @noindent
13184 Passive partitions are supported on targets where shared memory is
13185 provided by the operating system. See the GLADE reference manual for
13186 further details.
13187
13188 @sp 1
13189 @item
13190 @cartouche
13191 @noindent
13192 The information returned by @code{Exception_Message}. See
13193 11.4.1(10).
13194 @end cartouche
13195 @noindent
13196 Exception message returns the null string unless a specific message has
13197 been passed by the program.
13198
13199 @sp 1
13200 @item
13201 @cartouche
13202 @noindent
13203 The result of @code{Exceptions.Exception_Name} for types
13204 declared within an unnamed @code{block_statement}. See 11.4.1(12).
13205 @end cartouche
13206 @noindent
13207 Blocks have implementation defined names of the form @code{B@var{nnn}}
13208 where @var{nnn} is an integer.
13209
13210 @sp 1
13211 @item
13212 @cartouche
13213 @noindent
13214 The information returned by
13215 @code{Exception_Information}. See 11.4.1(13).
13216 @end cartouche
13217 @noindent
13218 @code{Exception_Information} returns a string in the following format:
13219
13220 @smallexample
13221 @emph{Exception_Name:} nnnnn
13222 @emph{Message:} mmmmm
13223 @emph{PID:} ppp
13224 @emph{Load address:} 0xhhhh
13225 @emph{Call stack traceback locations:}
13226 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
13227 @end smallexample
13228
13229 @noindent
13230 where
13231
13232 @itemize @bullet
13233 @item
13234 @code{nnnn} is the fully qualified name of the exception in all upper
13235 case letters. This line is always present.
13236
13237 @item
13238 @code{mmmm} is the message (this line present only if message is non-null)
13239
13240 @item
13241 @code{ppp} is the Process Id value as a decimal integer (this line is
13242 present only if the Process Id is nonzero). Currently we are
13243 not making use of this field.
13244
13245 @item
13246 The Load address line, the Call stack traceback locations line and the
13247 following values are present only if at least one traceback location was
13248 recorded. The Load address indicates the address at which the main executable
13249 was loaded; this line may not be present if operating system hasn't relocated
13250 the main executable. The values are given in C style format, with lower case
13251 letters for a-f, and only as many digits present as are necessary.
13252 @end itemize
13253
13254 @noindent
13255 The line terminator sequence at the end of each line, including
13256 the last line is a single @code{LF} character (@code{16#0A#}).
13257
13258 @sp 1
13259 @item
13260 @cartouche
13261 @noindent
13262 Implementation-defined check names. See 11.5(27).
13263 @end cartouche
13264 @noindent
13265 The implementation defined check name Alignment_Check controls checking of
13266 address clause values for proper alignment (that is, the address supplied
13267 must be consistent with the alignment of the type).
13268
13269 The implementation defined check name Predicate_Check controls whether
13270 predicate checks are generated.
13271
13272 The implementation defined check name Validity_Check controls whether
13273 validity checks are generated.
13274
13275 In addition, a user program can add implementation-defined check names
13276 by means of the pragma Check_Name.
13277
13278 @sp 1
13279 @item
13280 @cartouche
13281 @noindent
13282 The interpretation of each aspect of representation. See
13283 13.1(20).
13284 @end cartouche
13285 @noindent
13286 See separate section on data representations.
13287
13288 @sp 1
13289 @item
13290 @cartouche
13291 @noindent
13292 Any restrictions placed upon representation items. See
13293 13.1(20).
13294 @end cartouche
13295 @noindent
13296 See separate section on data representations.
13297
13298 @sp 1
13299 @item
13300 @cartouche
13301 @noindent
13302 The meaning of @code{Size} for indefinite subtypes. See
13303 13.3(48).
13304 @end cartouche
13305 @noindent
13306 Size for an indefinite subtype is the maximum possible size, except that
13307 for the case of a subprogram parameter, the size of the parameter object
13308 is the actual size.
13309
13310 @sp 1
13311 @item
13312 @cartouche
13313 @noindent
13314 The default external representation for a type tag. See
13315 13.3(75).
13316 @end cartouche
13317 @noindent
13318 The default external representation for a type tag is the fully expanded
13319 name of the type in upper case letters.
13320
13321 @sp 1
13322 @item
13323 @cartouche
13324 @noindent
13325 What determines whether a compilation unit is the same in
13326 two different partitions. See 13.3(76).
13327 @end cartouche
13328 @noindent
13329 A compilation unit is the same in two different partitions if and only
13330 if it derives from the same source file.
13331
13332 @sp 1
13333 @item
13334 @cartouche
13335 @noindent
13336 Implementation-defined components. See 13.5.1(15).
13337 @end cartouche
13338 @noindent
13339 The only implementation defined component is the tag for a tagged type,
13340 which contains a pointer to the dispatching table.
13341
13342 @sp 1
13343 @item
13344 @cartouche
13345 @noindent
13346 If @code{Word_Size} = @code{Storage_Unit}, the default bit
13347 ordering. See 13.5.3(5).
13348 @end cartouche
13349 @noindent
13350 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
13351 implementation, so no non-default bit ordering is supported. The default
13352 bit ordering corresponds to the natural endianness of the target architecture.
13353
13354 @sp 1
13355 @item
13356 @cartouche
13357 @noindent
13358 The contents of the visible part of package @code{System}
13359 and its language-defined children. See 13.7(2).
13360 @end cartouche
13361 @noindent
13362 See the definition of these packages in files @file{system.ads} and
13363 @file{s-stoele.ads}. Note that two declarations are added to package
13364 System.
13365
13366 @smallexample @c ada
13367 Max_Priority : constant Positive :=
13368 Priority'Last;
13369 Max_Interrupt_Priority : constant Positive :=
13370 Interrupt_Priority'Last;
13371 @end smallexample
13372
13373 @sp 1
13374 @item
13375 @cartouche
13376 @noindent
13377 The contents of the visible part of package
13378 @code{System.Machine_Code}, and the meaning of
13379 @code{code_statements}. See 13.8(7).
13380 @end cartouche
13381 @noindent
13382 See the definition and documentation in file @file{s-maccod.ads}.
13383
13384 @sp 1
13385 @item
13386 @cartouche
13387 @noindent
13388 The effect of unchecked conversion. See 13.9(11).
13389 @end cartouche
13390 @noindent
13391 Unchecked conversion between types of the same size
13392 results in an uninterpreted transmission of the bits from one type
13393 to the other. If the types are of unequal sizes, then in the case of
13394 discrete types, a shorter source is first zero or sign extended as
13395 necessary, and a shorter target is simply truncated on the left.
13396 For all non-discrete types, the source is first copied if necessary
13397 to ensure that the alignment requirements of the target are met, then
13398 a pointer is constructed to the source value, and the result is obtained
13399 by dereferencing this pointer after converting it to be a pointer to the
13400 target type. Unchecked conversions where the target subtype is an
13401 unconstrained array are not permitted. If the target alignment is
13402 greater than the source alignment, then a copy of the result is
13403 made with appropriate alignment
13404
13405 @sp 1
13406 @item
13407 @cartouche
13408 @noindent
13409 The semantics of operations on invalid representations.
13410 See 13.9.2(10-11).
13411 @end cartouche
13412 @noindent
13413 For assignments and other operations where the use of invalid values cannot
13414 result in erroneous behavior, the compiler ignores the possibility of invalid
13415 values. An exception is raised at the point where an invalid value would
13416 result in erroneous behavior. For example executing:
13417
13418 @smallexample @c ada
13419 procedure invalidvals is
13420 X : Integer := -1;
13421 Y : Natural range 1 .. 10;
13422 for Y'Address use X'Address;
13423 Z : Natural range 1 .. 10;
13424 A : array (Natural range 1 .. 10) of Integer;
13425 begin
13426 Z := Y; -- no exception
13427 A (Z) := 3; -- exception raised;
13428 end;
13429 @end smallexample
13430
13431 @noindent
13432 As indicated, an exception is raised on the array assignment, but not
13433 on the simple assignment of the invalid negative value from Y to Z.
13434
13435 @sp 1
13436 @item
13437 @cartouche
13438 @noindent
13439 The manner of choosing a storage pool for an access type
13440 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
13441 @end cartouche
13442 @noindent
13443 There are 3 different standard pools used by the compiler when
13444 @code{Storage_Pool} is not specified depending whether the type is local
13445 to a subprogram or defined at the library level and whether
13446 @code{Storage_Size}is specified or not. See documentation in the runtime
13447 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
13448 @code{System.Pool_Local} in files @file{s-poosiz.ads},
13449 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
13450 default pools used.
13451
13452 @sp 1
13453 @item
13454 @cartouche
13455 @noindent
13456 Whether or not the implementation provides user-accessible
13457 names for the standard pool type(s). See 13.11(17).
13458 @end cartouche
13459 @noindent
13460
13461 See documentation in the sources of the run time mentioned in the previous
13462 paragraph. All these pools are accessible by means of @code{with}'ing
13463 these units.
13464
13465 @sp 1
13466 @item
13467 @cartouche
13468 @noindent
13469 The meaning of @code{Storage_Size}. See 13.11(18).
13470 @end cartouche
13471 @noindent
13472 @code{Storage_Size} is measured in storage units, and refers to the
13473 total space available for an access type collection, or to the primary
13474 stack space for a task.
13475
13476 @sp 1
13477 @item
13478 @cartouche
13479 @noindent
13480 Implementation-defined aspects of storage pools. See
13481 13.11(22).
13482 @end cartouche
13483 @noindent
13484 See documentation in the sources of the run time mentioned in the
13485 paragraph about standard storage pools above
13486 for details on GNAT-defined aspects of storage pools.
13487
13488 @sp 1
13489 @item
13490 @cartouche
13491 @noindent
13492 The set of restrictions allowed in a pragma
13493 @code{Restrictions}. See 13.12(7).
13494 @end cartouche
13495 @noindent
13496 @xref{Standard and Implementation Defined Restrictions}.
13497
13498 @sp 1
13499 @item
13500 @cartouche
13501 @noindent
13502 The consequences of violating limitations on
13503 @code{Restrictions} pragmas. See 13.12(9).
13504 @end cartouche
13505 @noindent
13506 Restrictions that can be checked at compile time result in illegalities
13507 if violated. Currently there are no other consequences of violating
13508 restrictions.
13509
13510 @sp 1
13511 @item
13512 @cartouche
13513 @noindent
13514 The representation used by the @code{Read} and
13515 @code{Write} attributes of elementary types in terms of stream
13516 elements. See 13.13.2(9).
13517 @end cartouche
13518 @noindent
13519 The representation is the in-memory representation of the base type of
13520 the type, using the number of bits corresponding to the
13521 @code{@var{type}'Size} value, and the natural ordering of the machine.
13522
13523 @sp 1
13524 @item
13525 @cartouche
13526 @noindent
13527 The names and characteristics of the numeric subtypes
13528 declared in the visible part of package @code{Standard}. See A.1(3).
13529 @end cartouche
13530 @noindent
13531 See items describing the integer and floating-point types supported.
13532
13533 @sp 1
13534 @item
13535 @cartouche
13536 @noindent
13537 The string returned by @code{Character_Set_Version}.
13538 See A.3.5(3).
13539 @end cartouche
13540 @noindent
13541 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
13542 the string "Unicode 4.0", referring to version 4.0 of the
13543 Unicode specification.
13544
13545 @sp 1
13546 @item
13547 @cartouche
13548 @noindent
13549 The accuracy actually achieved by the elementary
13550 functions. See A.5.1(1).
13551 @end cartouche
13552 @noindent
13553 The elementary functions correspond to the functions available in the C
13554 library. Only fast math mode is implemented.
13555
13556 @sp 1
13557 @item
13558 @cartouche
13559 @noindent
13560 The sign of a zero result from some of the operators or
13561 functions in @code{Numerics.Generic_Elementary_Functions}, when
13562 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
13563 @end cartouche
13564 @noindent
13565 The sign of zeroes follows the requirements of the IEEE 754 standard on
13566 floating-point.
13567
13568 @sp 1
13569 @item
13570 @cartouche
13571 @noindent
13572 The value of
13573 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
13574 @end cartouche
13575 @noindent
13576 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13577
13578 @sp 1
13579 @item
13580 @cartouche
13581 @noindent
13582 The value of
13583 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
13584 @end cartouche
13585 @noindent
13586 Maximum image width is 6864, see library file @file{s-rannum.ads}.
13587
13588 @sp 1
13589 @item
13590 @cartouche
13591 @noindent
13592 The algorithms for random number generation. See
13593 A.5.2(32).
13594 @end cartouche
13595 @noindent
13596 The algorithm is the Mersenne Twister, as documented in the source file
13597 @file{s-rannum.adb}. This version of the algorithm has a period of
13598 2**19937-1.
13599
13600 @sp 1
13601 @item
13602 @cartouche
13603 @noindent
13604 The string representation of a random number generator's
13605 state. See A.5.2(38).
13606 @end cartouche
13607 @noindent
13608 The value returned by the Image function is the concatenation of
13609 the fixed-width decimal representations of the 624 32-bit integers
13610 of the state vector.
13611
13612 @sp 1
13613 @item
13614 @cartouche
13615 @noindent
13616 The minimum time interval between calls to the
13617 time-dependent Reset procedure that are guaranteed to initiate different
13618 random number sequences. See A.5.2(45).
13619 @end cartouche
13620 @noindent
13621 The minimum period between reset calls to guarantee distinct series of
13622 random numbers is one microsecond.
13623
13624 @sp 1
13625 @item
13626 @cartouche
13627 @noindent
13628 The values of the @code{Model_Mantissa},
13629 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
13630 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
13631 Annex is not supported. See A.5.3(72).
13632 @end cartouche
13633 @noindent
13634 Run the compiler with @option{-gnatS} to produce a listing of package
13635 @code{Standard}, has the values of all numeric attributes.
13636
13637 @sp 1
13638 @item
13639 @cartouche
13640 @noindent
13641 Any implementation-defined characteristics of the
13642 input-output packages. See A.7(14).
13643 @end cartouche
13644 @noindent
13645 There are no special implementation defined characteristics for these
13646 packages.
13647
13648 @sp 1
13649 @item
13650 @cartouche
13651 @noindent
13652 The value of @code{Buffer_Size} in @code{Storage_IO}. See
13653 A.9(10).
13654 @end cartouche
13655 @noindent
13656 All type representations are contiguous, and the @code{Buffer_Size} is
13657 the value of @code{@var{type}'Size} rounded up to the next storage unit
13658 boundary.
13659
13660 @sp 1
13661 @item
13662 @cartouche
13663 @noindent
13664 External files for standard input, standard output, and
13665 standard error See A.10(5).
13666 @end cartouche
13667 @noindent
13668 These files are mapped onto the files provided by the C streams
13669 libraries. See source file @file{i-cstrea.ads} for further details.
13670
13671 @sp 1
13672 @item
13673 @cartouche
13674 @noindent
13675 The accuracy of the value produced by @code{Put}. See
13676 A.10.9(36).
13677 @end cartouche
13678 @noindent
13679 If more digits are requested in the output than are represented by the
13680 precision of the value, zeroes are output in the corresponding least
13681 significant digit positions.
13682
13683 @sp 1
13684 @item
13685 @cartouche
13686 @noindent
13687 The meaning of @code{Argument_Count}, @code{Argument}, and
13688 @code{Command_Name}. See A.15(1).
13689 @end cartouche
13690 @noindent
13691 These are mapped onto the @code{argv} and @code{argc} parameters of the
13692 main program in the natural manner.
13693
13694 @sp 1
13695 @item
13696 @cartouche
13697 @noindent
13698 The interpretation of the @code{Form} parameter in procedure
13699 @code{Create_Directory}. See A.16(56).
13700 @end cartouche
13701 @noindent
13702 The @code{Form} parameter is not used.
13703
13704 @sp 1
13705 @item
13706 @cartouche
13707 @noindent
13708 The interpretation of the @code{Form} parameter in procedure
13709 @code{Create_Path}. See A.16(60).
13710 @end cartouche
13711 @noindent
13712 The @code{Form} parameter is not used.
13713
13714 @sp 1
13715 @item
13716 @cartouche
13717 @noindent
13718 The interpretation of the @code{Form} parameter in procedure
13719 @code{Copy_File}. See A.16(68).
13720 @end cartouche
13721 @noindent
13722 The @code{Form} parameter is case-insensitive.
13723
13724 Two fields are recognized in the @code{Form} parameter:
13725
13726 @table @code
13727
13728 @item preserve=<value>
13729
13730 @item mode=<value>
13731
13732 @end table
13733
13734 @noindent
13735 <value> starts immediately after the character '=' and ends with the
13736 character immediately preceding the next comma (',') or with the last
13737 character of the parameter.
13738
13739 The only possible values for preserve= are:
13740
13741 @table @code
13742
13743 @item no_attributes
13744 Do not try to preserve any file attributes. This is the default if no
13745 preserve= is found in Form.
13746
13747 @item all_attributes
13748 Try to preserve all file attributes (timestamps, access rights).
13749
13750 @item timestamps
13751 Preserve the timestamp of the copied file, but not the other file attributes.
13752
13753 @end table
13754
13755 @noindent
13756 The only possible values for mode= are:
13757
13758 @table @code
13759
13760 @item copy
13761 Only do the copy if the destination file does not already exist. If it already
13762 exists, Copy_File fails.
13763
13764 @item overwrite
13765 Copy the file in all cases. Overwrite an already existing destination file.
13766
13767 @item append
13768 Append the original file to the destination file. If the destination file does
13769 not exist, the destination file is a copy of the source file. When mode=append,
13770 the field preserve=, if it exists, is not taken into account.
13771
13772 @end table
13773
13774 @noindent
13775 If the Form parameter includes one or both of the fields and the value or
13776 values are incorrect, Copy_file fails with Use_Error.
13777
13778 Examples of correct Forms:
13779
13780 @smallexample
13781 Form => "preserve=no_attributes,mode=overwrite" (the default)
13782 Form => "mode=append"
13783 Form => "mode=copy, preserve=all_attributes"
13784 @end smallexample
13785
13786 @noindent
13787 Examples of incorrect Forms
13788
13789 @smallexample
13790 Form => "preserve=junk"
13791 Form => "mode=internal, preserve=timestamps"
13792 @end smallexample
13793
13794 @sp 1
13795 @item
13796 @cartouche
13797 @noindent
13798 The interpretation of the @code{Pattern} parameter, when not the null string,
13799 in the @code{Start_Search} and @code{Search} procedures.
13800 See A.16(104) and A.16(112).
13801 @end cartouche
13802 @noindent
13803 When the @code{Pattern} parameter is not the null string, it is interpreted
13804 according to the syntax of regular expressions as defined in the
13805 @code{GNAT.Regexp} package.
13806 @xref{GNAT.Regexp (g-regexp.ads)}.
13807
13808 @sp 1
13809 @item
13810 @cartouche
13811 @noindent
13812 Implementation-defined convention names. See B.1(11).
13813 @end cartouche
13814 @noindent
13815 The following convention names are supported
13816
13817 @table @code
13818 @item Ada
13819 Ada
13820 @item Ada_Pass_By_Copy
13821 Allowed for any types except by-reference types such as limited
13822 records. Compatible with convention Ada, but causes any parameters
13823 with this convention to be passed by copy.
13824 @item Ada_Pass_By_Reference
13825 Allowed for any types except by-copy types such as scalars.
13826 Compatible with convention Ada, but causes any parameters
13827 with this convention to be passed by reference.
13828 @item Assembler
13829 Assembly language
13830 @item Asm
13831 Synonym for Assembler
13832 @item Assembly
13833 Synonym for Assembler
13834 @item C
13835 C
13836 @item C_Pass_By_Copy
13837 Allowed only for record types, like C, but also notes that record
13838 is to be passed by copy rather than reference.
13839 @item COBOL
13840 COBOL
13841 @item C_Plus_Plus (or CPP)
13842 C++
13843 @item Default
13844 Treated the same as C
13845 @item External
13846 Treated the same as C
13847 @item Fortran
13848 Fortran
13849 @item Intrinsic
13850 For support of pragma @code{Import} with convention Intrinsic, see
13851 separate section on Intrinsic Subprograms.
13852 @item Stdcall
13853 Stdcall (used for Windows implementations only). This convention correspond
13854 to the WINAPI (previously called Pascal convention) C/C++ convention under
13855 Windows. A routine with this convention cleans the stack before
13856 exit. This pragma cannot be applied to a dispatching call.
13857 @item DLL
13858 Synonym for Stdcall
13859 @item Win32
13860 Synonym for Stdcall
13861 @item Stubbed
13862 Stubbed is a special convention used to indicate that the body of the
13863 subprogram will be entirely ignored. Any call to the subprogram
13864 is converted into a raise of the @code{Program_Error} exception. If a
13865 pragma @code{Import} specifies convention @code{stubbed} then no body need
13866 be present at all. This convention is useful during development for the
13867 inclusion of subprograms whose body has not yet been written.
13868
13869 @end table
13870 @noindent
13871 In addition, all otherwise unrecognized convention names are also
13872 treated as being synonymous with convention C@. In all implementations
13873 except for VMS, use of such other names results in a warning. In VMS
13874 implementations, these names are accepted silently.
13875
13876 @sp 1
13877 @item
13878 @cartouche
13879 @noindent
13880 The meaning of link names. See B.1(36).
13881 @end cartouche
13882 @noindent
13883 Link names are the actual names used by the linker.
13884
13885 @sp 1
13886 @item
13887 @cartouche
13888 @noindent
13889 The manner of choosing link names when neither the link
13890 name nor the address of an imported or exported entity is specified. See
13891 B.1(36).
13892 @end cartouche
13893 @noindent
13894 The default linker name is that which would be assigned by the relevant
13895 external language, interpreting the Ada name as being in all lower case
13896 letters.
13897
13898 @sp 1
13899 @item
13900 @cartouche
13901 @noindent
13902 The effect of pragma @code{Linker_Options}. See B.1(37).
13903 @end cartouche
13904 @noindent
13905 The string passed to @code{Linker_Options} is presented uninterpreted as
13906 an argument to the link command, unless it contains ASCII.NUL characters.
13907 NUL characters if they appear act as argument separators, so for example
13908
13909 @smallexample @c ada
13910 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
13911 @end smallexample
13912
13913 @noindent
13914 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
13915 linker. The order of linker options is preserved for a given unit. The final
13916 list of options passed to the linker is in reverse order of the elaboration
13917 order. For example, linker options for a body always appear before the options
13918 from the corresponding package spec.
13919
13920 @sp 1
13921 @item
13922 @cartouche
13923 @noindent
13924 The contents of the visible part of package
13925 @code{Interfaces} and its language-defined descendants. See B.2(1).
13926 @end cartouche
13927 @noindent
13928 See files with prefix @file{i-} in the distributed library.
13929
13930 @sp 1
13931 @item
13932 @cartouche
13933 @noindent
13934 Implementation-defined children of package
13935 @code{Interfaces}. The contents of the visible part of package
13936 @code{Interfaces}. See B.2(11).
13937 @end cartouche
13938 @noindent
13939 See files with prefix @file{i-} in the distributed library.
13940
13941 @sp 1
13942 @item
13943 @cartouche
13944 @noindent
13945 The types @code{Floating}, @code{Long_Floating},
13946 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
13947 @code{COBOL_Character}; and the initialization of the variables
13948 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
13949 @code{Interfaces.COBOL}. See B.4(50).
13950 @end cartouche
13951 @noindent
13952 @table @code
13953 @item Floating
13954 Float
13955 @item Long_Floating
13956 (Floating) Long_Float
13957 @item Binary
13958 Integer
13959 @item Long_Binary
13960 Long_Long_Integer
13961 @item Decimal_Element
13962 Character
13963 @item COBOL_Character
13964 Character
13965 @end table
13966
13967 @noindent
13968 For initialization, see the file @file{i-cobol.ads} in the distributed library.
13969
13970 @sp 1
13971 @item
13972 @cartouche
13973 @noindent
13974 Support for access to machine instructions. See C.1(1).
13975 @end cartouche
13976 @noindent
13977 See documentation in file @file{s-maccod.ads} in the distributed library.
13978
13979 @sp 1
13980 @item
13981 @cartouche
13982 @noindent
13983 Implementation-defined aspects of access to machine
13984 operations. See C.1(9).
13985 @end cartouche
13986 @noindent
13987 See documentation in file @file{s-maccod.ads} in the distributed library.
13988
13989 @sp 1
13990 @item
13991 @cartouche
13992 @noindent
13993 Implementation-defined aspects of interrupts. See C.3(2).
13994 @end cartouche
13995 @noindent
13996 Interrupts are mapped to signals or conditions as appropriate. See
13997 definition of unit
13998 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
13999 on the interrupts supported on a particular target.
14000
14001 @sp 1
14002 @item
14003 @cartouche
14004 @noindent
14005 Implementation-defined aspects of pre-elaboration. See
14006 C.4(13).
14007 @end cartouche
14008 @noindent
14009 GNAT does not permit a partition to be restarted without reloading,
14010 except under control of the debugger.
14011
14012 @sp 1
14013 @item
14014 @cartouche
14015 @noindent
14016 The semantics of pragma @code{Discard_Names}. See C.5(7).
14017 @end cartouche
14018 @noindent
14019 Pragma @code{Discard_Names} causes names of enumeration literals to
14020 be suppressed. In the presence of this pragma, the Image attribute
14021 provides the image of the Pos of the literal, and Value accepts
14022 Pos values.
14023
14024 @sp 1
14025 @item
14026 @cartouche
14027 @noindent
14028 The result of the @code{Task_Identification.Image}
14029 attribute. See C.7.1(7).
14030 @end cartouche
14031 @noindent
14032 The result of this attribute is a string that identifies
14033 the object or component that denotes a given task. If a variable @code{Var}
14034 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
14035 where the suffix
14036 is the hexadecimal representation of the virtual address of the corresponding
14037 task control block. If the variable is an array of tasks, the image of each
14038 task will have the form of an indexed component indicating the position of a
14039 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
14040 component of a record, the image of the task will have the form of a selected
14041 component. These rules are fully recursive, so that the image of a task that
14042 is a subcomponent of a composite object corresponds to the expression that
14043 designates this task.
14044 @noindent
14045 If a task is created by an allocator, its image depends on the context. If the
14046 allocator is part of an object declaration, the rules described above are used
14047 to construct its image, and this image is not affected by subsequent
14048 assignments. If the allocator appears within an expression, the image
14049 includes only the name of the task type.
14050 @noindent
14051 If the configuration pragma Discard_Names is present, or if the restriction
14052 No_Implicit_Heap_Allocation is in effect, the image reduces to
14053 the numeric suffix, that is to say the hexadecimal representation of the
14054 virtual address of the control block of the task.
14055 @sp 1
14056 @item
14057 @cartouche
14058 @noindent
14059 The value of @code{Current_Task} when in a protected entry
14060 or interrupt handler. See C.7.1(17).
14061 @end cartouche
14062 @noindent
14063 Protected entries or interrupt handlers can be executed by any
14064 convenient thread, so the value of @code{Current_Task} is undefined.
14065
14066 @sp 1
14067 @item
14068 @cartouche
14069 @noindent
14070 The effect of calling @code{Current_Task} from an entry
14071 body or interrupt handler. See C.7.1(19).
14072 @end cartouche
14073 @noindent
14074 The effect of calling @code{Current_Task} from an entry body or
14075 interrupt handler is to return the identification of the task currently
14076 executing the code.
14077
14078 @sp 1
14079 @item
14080 @cartouche
14081 @noindent
14082 Implementation-defined aspects of
14083 @code{Task_Attributes}. See C.7.2(19).
14084 @end cartouche
14085 @noindent
14086 There are no implementation-defined aspects of @code{Task_Attributes}.
14087
14088 @sp 1
14089 @item
14090 @cartouche
14091 @noindent
14092 Values of all @code{Metrics}. See D(2).
14093 @end cartouche
14094 @noindent
14095 The metrics information for GNAT depends on the performance of the
14096 underlying operating system. The sources of the run-time for tasking
14097 implementation, together with the output from @option{-gnatG} can be
14098 used to determine the exact sequence of operating systems calls made
14099 to implement various tasking constructs. Together with appropriate
14100 information on the performance of the underlying operating system,
14101 on the exact target in use, this information can be used to determine
14102 the required metrics.
14103
14104 @sp 1
14105 @item
14106 @cartouche
14107 @noindent
14108 The declarations of @code{Any_Priority} and
14109 @code{Priority}. See D.1(11).
14110 @end cartouche
14111 @noindent
14112 See declarations in file @file{system.ads}.
14113
14114 @sp 1
14115 @item
14116 @cartouche
14117 @noindent
14118 Implementation-defined execution resources. See D.1(15).
14119 @end cartouche
14120 @noindent
14121 There are no implementation-defined execution resources.
14122
14123 @sp 1
14124 @item
14125 @cartouche
14126 @noindent
14127 Whether, on a multiprocessor, a task that is waiting for
14128 access to a protected object keeps its processor busy. See D.2.1(3).
14129 @end cartouche
14130 @noindent
14131 On a multi-processor, a task that is waiting for access to a protected
14132 object does not keep its processor busy.
14133
14134 @sp 1
14135 @item
14136 @cartouche
14137 @noindent
14138 The affect of implementation defined execution resources
14139 on task dispatching. See D.2.1(9).
14140 @end cartouche
14141 @noindent
14142 Tasks map to threads in the threads package used by GNAT@. Where possible
14143 and appropriate, these threads correspond to native threads of the
14144 underlying operating system.
14145
14146 @sp 1
14147 @item
14148 @cartouche
14149 @noindent
14150 Implementation-defined @code{policy_identifiers} allowed
14151 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
14152 @end cartouche
14153 @noindent
14154 There are no implementation-defined policy-identifiers allowed in this
14155 pragma.
14156
14157 @sp 1
14158 @item
14159 @cartouche
14160 @noindent
14161 Implementation-defined aspects of priority inversion. See
14162 D.2.2(16).
14163 @end cartouche
14164 @noindent
14165 Execution of a task cannot be preempted by the implementation processing
14166 of delay expirations for lower priority tasks.
14167
14168 @sp 1
14169 @item
14170 @cartouche
14171 @noindent
14172 Implementation-defined task dispatching. See D.2.2(18).
14173 @end cartouche
14174 @noindent
14175 The policy is the same as that of the underlying threads implementation.
14176
14177 @sp 1
14178 @item
14179 @cartouche
14180 @noindent
14181 Implementation-defined @code{policy_identifiers} allowed
14182 in a pragma @code{Locking_Policy}. See D.3(4).
14183 @end cartouche
14184 @noindent
14185 The two implementation defined policies permitted in GNAT are
14186 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
14187 targets that support the @code{Inheritance_Locking} policy, locking is
14188 implemented by inheritance, i.e.@: the task owning the lock operates
14189 at a priority equal to the highest priority of any task currently
14190 requesting the lock. On targets that support the
14191 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
14192 read/write lock allowing multiple propected object functions to enter
14193 concurrently.
14194
14195 @sp 1
14196 @item
14197 @cartouche
14198 @noindent
14199 Default ceiling priorities. See D.3(10).
14200 @end cartouche
14201 @noindent
14202 The ceiling priority of protected objects of the type
14203 @code{System.Interrupt_Priority'Last} as described in the Ada
14204 Reference Manual D.3(10),
14205
14206 @sp 1
14207 @item
14208 @cartouche
14209 @noindent
14210 The ceiling of any protected object used internally by
14211 the implementation. See D.3(16).
14212 @end cartouche
14213 @noindent
14214 The ceiling priority of internal protected objects is
14215 @code{System.Priority'Last}.
14216
14217 @sp 1
14218 @item
14219 @cartouche
14220 @noindent
14221 Implementation-defined queuing policies. See D.4(1).
14222 @end cartouche
14223 @noindent
14224 There are no implementation-defined queuing policies.
14225
14226 @sp 1
14227 @item
14228 @cartouche
14229 @noindent
14230 On a multiprocessor, any conditions that cause the
14231 completion of an aborted construct to be delayed later than what is
14232 specified for a single processor. See D.6(3).
14233 @end cartouche
14234 @noindent
14235 The semantics for abort on a multi-processor is the same as on a single
14236 processor, there are no further delays.
14237
14238 @sp 1
14239 @item
14240 @cartouche
14241 @noindent
14242 Any operations that implicitly require heap storage
14243 allocation. See D.7(8).
14244 @end cartouche
14245 @noindent
14246 The only operation that implicitly requires heap storage allocation is
14247 task creation.
14248
14249 @sp 1
14250 @item
14251 @cartouche
14252 @noindent
14253 Implementation-defined aspects of pragma
14254 @code{Restrictions}. See D.7(20).
14255 @end cartouche
14256 @noindent
14257 There are no such implementation-defined aspects.
14258
14259 @sp 1
14260 @item
14261 @cartouche
14262 @noindent
14263 Implementation-defined aspects of package
14264 @code{Real_Time}. See D.8(17).
14265 @end cartouche
14266 @noindent
14267 There are no implementation defined aspects of package @code{Real_Time}.
14268
14269 @sp 1
14270 @item
14271 @cartouche
14272 @noindent
14273 Implementation-defined aspects of
14274 @code{delay_statements}. See D.9(8).
14275 @end cartouche
14276 @noindent
14277 Any difference greater than one microsecond will cause the task to be
14278 delayed (see D.9(7)).
14279
14280 @sp 1
14281 @item
14282 @cartouche
14283 @noindent
14284 The upper bound on the duration of interrupt blocking
14285 caused by the implementation. See D.12(5).
14286 @end cartouche
14287 @noindent
14288 The upper bound is determined by the underlying operating system. In
14289 no cases is it more than 10 milliseconds.
14290
14291 @sp 1
14292 @item
14293 @cartouche
14294 @noindent
14295 The means for creating and executing distributed
14296 programs. See E(5).
14297 @end cartouche
14298 @noindent
14299 The GLADE package provides a utility GNATDIST for creating and executing
14300 distributed programs. See the GLADE reference manual for further details.
14301
14302 @sp 1
14303 @item
14304 @cartouche
14305 @noindent
14306 Any events that can result in a partition becoming
14307 inaccessible. See E.1(7).
14308 @end cartouche
14309 @noindent
14310 See the GLADE reference manual for full details on such events.
14311
14312 @sp 1
14313 @item
14314 @cartouche
14315 @noindent
14316 The scheduling policies, treatment of priorities, and
14317 management of shared resources between partitions in certain cases. See
14318 E.1(11).
14319 @end cartouche
14320 @noindent
14321 See the GLADE reference manual for full details on these aspects of
14322 multi-partition execution.
14323
14324 @sp 1
14325 @item
14326 @cartouche
14327 @noindent
14328 Events that cause the version of a compilation unit to
14329 change. See E.3(5).
14330 @end cartouche
14331 @noindent
14332 Editing the source file of a compilation unit, or the source files of
14333 any units on which it is dependent in a significant way cause the version
14334 to change. No other actions cause the version number to change. All changes
14335 are significant except those which affect only layout, capitalization or
14336 comments.
14337
14338 @sp 1
14339 @item
14340 @cartouche
14341 @noindent
14342 Whether the execution of the remote subprogram is
14343 immediately aborted as a result of cancellation. See E.4(13).
14344 @end cartouche
14345 @noindent
14346 See the GLADE reference manual for details on the effect of abort in
14347 a distributed application.
14348
14349 @sp 1
14350 @item
14351 @cartouche
14352 @noindent
14353 Implementation-defined aspects of the PCS@. See E.5(25).
14354 @end cartouche
14355 @noindent
14356 See the GLADE reference manual for a full description of all implementation
14357 defined aspects of the PCS@.
14358
14359 @sp 1
14360 @item
14361 @cartouche
14362 @noindent
14363 Implementation-defined interfaces in the PCS@. See
14364 E.5(26).
14365 @end cartouche
14366 @noindent
14367 See the GLADE reference manual for a full description of all
14368 implementation defined interfaces.
14369
14370 @sp 1
14371 @item
14372 @cartouche
14373 @noindent
14374 The values of named numbers in the package
14375 @code{Decimal}. See F.2(7).
14376 @end cartouche
14377 @noindent
14378 @table @code
14379 @item Max_Scale
14380 +18
14381 @item Min_Scale
14382 -18
14383 @item Min_Delta
14384 1.0E-18
14385 @item Max_Delta
14386 1.0E+18
14387 @item Max_Decimal_Digits
14388 18
14389 @end table
14390
14391 @sp 1
14392 @item
14393 @cartouche
14394 @noindent
14395 The value of @code{Max_Picture_Length} in the package
14396 @code{Text_IO.Editing}. See F.3.3(16).
14397 @end cartouche
14398 @noindent
14399 64
14400
14401 @sp 1
14402 @item
14403 @cartouche
14404 @noindent
14405 The value of @code{Max_Picture_Length} in the package
14406 @code{Wide_Text_IO.Editing}. See F.3.4(5).
14407 @end cartouche
14408 @noindent
14409 64
14410
14411 @sp 1
14412 @item
14413 @cartouche
14414 @noindent
14415 The accuracy actually achieved by the complex elementary
14416 functions and by other complex arithmetic operations. See G.1(1).
14417 @end cartouche
14418 @noindent
14419 Standard library functions are used for the complex arithmetic
14420 operations. Only fast math mode is currently supported.
14421
14422 @sp 1
14423 @item
14424 @cartouche
14425 @noindent
14426 The sign of a zero result (or a component thereof) from
14427 any operator or function in @code{Numerics.Generic_Complex_Types}, when
14428 @code{Real'Signed_Zeros} is True. See G.1.1(53).
14429 @end cartouche
14430 @noindent
14431 The signs of zero values are as recommended by the relevant
14432 implementation advice.
14433
14434 @sp 1
14435 @item
14436 @cartouche
14437 @noindent
14438 The sign of a zero result (or a component thereof) from
14439 any operator or function in
14440 @code{Numerics.Generic_Complex_Elementary_Functions}, when
14441 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
14442 @end cartouche
14443 @noindent
14444 The signs of zero values are as recommended by the relevant
14445 implementation advice.
14446
14447 @sp 1
14448 @item
14449 @cartouche
14450 @noindent
14451 Whether the strict mode or the relaxed mode is the
14452 default. See G.2(2).
14453 @end cartouche
14454 @noindent
14455 The strict mode is the default. There is no separate relaxed mode. GNAT
14456 provides a highly efficient implementation of strict mode.
14457
14458 @sp 1
14459 @item
14460 @cartouche
14461 @noindent
14462 The result interval in certain cases of fixed-to-float
14463 conversion. See G.2.1(10).
14464 @end cartouche
14465 @noindent
14466 For cases where the result interval is implementation dependent, the
14467 accuracy is that provided by performing all operations in 64-bit IEEE
14468 floating-point format.
14469
14470 @sp 1
14471 @item
14472 @cartouche
14473 @noindent
14474 The result of a floating point arithmetic operation in
14475 overflow situations, when the @code{Machine_Overflows} attribute of the
14476 result type is @code{False}. See G.2.1(13).
14477 @end cartouche
14478 @noindent
14479 Infinite and NaN values are produced as dictated by the IEEE
14480 floating-point standard.
14481
14482 Note that on machines that are not fully compliant with the IEEE
14483 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
14484 must be used for achieving IEEE conforming behavior (although at the cost
14485 of a significant performance penalty), so infinite and NaN values are
14486 properly generated.
14487
14488 @sp 1
14489 @item
14490 @cartouche
14491 @noindent
14492 The result interval for division (or exponentiation by a
14493 negative exponent), when the floating point hardware implements division
14494 as multiplication by a reciprocal. See G.2.1(16).
14495 @end cartouche
14496 @noindent
14497 Not relevant, division is IEEE exact.
14498
14499 @sp 1
14500 @item
14501 @cartouche
14502 @noindent
14503 The definition of close result set, which determines the
14504 accuracy of certain fixed point multiplications and divisions. See
14505 G.2.3(5).
14506 @end cartouche
14507 @noindent
14508 Operations in the close result set are performed using IEEE long format
14509 floating-point arithmetic. The input operands are converted to
14510 floating-point, the operation is done in floating-point, and the result
14511 is converted to the target type.
14512
14513 @sp 1
14514 @item
14515 @cartouche
14516 @noindent
14517 Conditions on a @code{universal_real} operand of a fixed
14518 point multiplication or division for which the result shall be in the
14519 perfect result set. See G.2.3(22).
14520 @end cartouche
14521 @noindent
14522 The result is only defined to be in the perfect result set if the result
14523 can be computed by a single scaling operation involving a scale factor
14524 representable in 64-bits.
14525
14526 @sp 1
14527 @item
14528 @cartouche
14529 @noindent
14530 The result of a fixed point arithmetic operation in
14531 overflow situations, when the @code{Machine_Overflows} attribute of the
14532 result type is @code{False}. See G.2.3(27).
14533 @end cartouche
14534 @noindent
14535 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
14536 types.
14537
14538 @sp 1
14539 @item
14540 @cartouche
14541 @noindent
14542 The result of an elementary function reference in
14543 overflow situations, when the @code{Machine_Overflows} attribute of the
14544 result type is @code{False}. See G.2.4(4).
14545 @end cartouche
14546 @noindent
14547 IEEE infinite and Nan values are produced as appropriate.
14548
14549 @sp 1
14550 @item
14551 @cartouche
14552 @noindent
14553 The value of the angle threshold, within which certain
14554 elementary functions, complex arithmetic operations, and complex
14555 elementary functions yield results conforming to a maximum relative
14556 error bound. See G.2.4(10).
14557 @end cartouche
14558 @noindent
14559 Information on this subject is not yet available.
14560
14561 @sp 1
14562 @item
14563 @cartouche
14564 @noindent
14565 The accuracy of certain elementary functions for
14566 parameters beyond the angle threshold. See G.2.4(10).
14567 @end cartouche
14568 @noindent
14569 Information on this subject is not yet available.
14570
14571 @sp 1
14572 @item
14573 @cartouche
14574 @noindent
14575 The result of a complex arithmetic operation or complex
14576 elementary function reference in overflow situations, when the
14577 @code{Machine_Overflows} attribute of the corresponding real type is
14578 @code{False}. See G.2.6(5).
14579 @end cartouche
14580 @noindent
14581 IEEE infinite and Nan values are produced as appropriate.
14582
14583 @sp 1
14584 @item
14585 @cartouche
14586 @noindent
14587 The accuracy of certain complex arithmetic operations and
14588 certain complex elementary functions for parameters (or components
14589 thereof) beyond the angle threshold. See G.2.6(8).
14590 @end cartouche
14591 @noindent
14592 Information on those subjects is not yet available.
14593
14594 @sp 1
14595 @item
14596 @cartouche
14597 @noindent
14598 Information regarding bounded errors and erroneous
14599 execution. See H.2(1).
14600 @end cartouche
14601 @noindent
14602 Information on this subject is not yet available.
14603
14604 @sp 1
14605 @item
14606 @cartouche
14607 @noindent
14608 Implementation-defined aspects of pragma
14609 @code{Inspection_Point}. See H.3.2(8).
14610 @end cartouche
14611 @noindent
14612 Pragma @code{Inspection_Point} ensures that the variable is live and can
14613 be examined by the debugger at the inspection point.
14614
14615 @sp 1
14616 @item
14617 @cartouche
14618 @noindent
14619 Implementation-defined aspects of pragma
14620 @code{Restrictions}. See H.4(25).
14621 @end cartouche
14622 @noindent
14623 There are no implementation-defined aspects of pragma @code{Restrictions}. The
14624 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
14625 generated code. Checks must suppressed by use of pragma @code{Suppress}.
14626
14627 @sp 1
14628 @item
14629 @cartouche
14630 @noindent
14631 Any restrictions on pragma @code{Restrictions}. See
14632 H.4(27).
14633 @end cartouche
14634 @noindent
14635 There are no restrictions on pragma @code{Restrictions}.
14636
14637 @end itemize
14638
14639
14640 @c =======================
14641 @node Intrinsic Subprograms
14642 @chapter Intrinsic Subprograms
14643 @cindex Intrinsic Subprograms
14644
14645 @menu
14646 * Intrinsic Operators::
14647 * Compilation_Date::
14648 * Compilation_Time::
14649 * Enclosing_Entity::
14650 * Exception_Information::
14651 * Exception_Message::
14652 * Exception_Name::
14653 * File::
14654 * Line::
14655 * Shifts and Rotates::
14656 * Source_Location::
14657 @end menu
14658
14659 @noindent
14660 GNAT allows a user application program to write the declaration:
14661
14662 @smallexample @c ada
14663 pragma Import (Intrinsic, name);
14664 @end smallexample
14665
14666 @noindent
14667 providing that the name corresponds to one of the implemented intrinsic
14668 subprograms in GNAT, and that the parameter profile of the referenced
14669 subprogram meets the requirements. This chapter describes the set of
14670 implemented intrinsic subprograms, and the requirements on parameter profiles.
14671 Note that no body is supplied; as with other uses of pragma Import, the
14672 body is supplied elsewhere (in this case by the compiler itself). Note
14673 that any use of this feature is potentially non-portable, since the
14674 Ada standard does not require Ada compilers to implement this feature.
14675
14676 @node Intrinsic Operators
14677 @section Intrinsic Operators
14678 @cindex Intrinsic operator
14679
14680 @noindent
14681 All the predefined numeric operators in package Standard
14682 in @code{pragma Import (Intrinsic,..)}
14683 declarations. In the binary operator case, the operands must have the same
14684 size. The operand or operands must also be appropriate for
14685 the operator. For example, for addition, the operands must
14686 both be floating-point or both be fixed-point, and the
14687 right operand for @code{"**"} must have a root type of
14688 @code{Standard.Integer'Base}.
14689 You can use an intrinsic operator declaration as in the following example:
14690
14691 @smallexample @c ada
14692 type Int1 is new Integer;
14693 type Int2 is new Integer;
14694
14695 function "+" (X1 : Int1; X2 : Int2) return Int1;
14696 function "+" (X1 : Int1; X2 : Int2) return Int2;
14697 pragma Import (Intrinsic, "+");
14698 @end smallexample
14699
14700 @noindent
14701 This declaration would permit ``mixed mode'' arithmetic on items
14702 of the differing types @code{Int1} and @code{Int2}.
14703 It is also possible to specify such operators for private types, if the
14704 full views are appropriate arithmetic types.
14705
14706 @node Compilation_Date
14707 @section Compilation_Date
14708 @cindex Compilation_Date
14709 @noindent
14710 This intrinsic subprogram is used in the implementation of the
14711 library package @code{GNAT.Source_Info}. The only useful use of the
14712 intrinsic import in this case is the one in this unit, so an
14713 application program should simply call the function
14714 @code{GNAT.Source_Info.Compilation_Date} to obtain the date of
14715 the current compilation (in local time format MMM DD YYYY).
14716
14717 @node Compilation_Time
14718 @section Compilation_Time
14719 @cindex Compilation_Time
14720 @noindent
14721 This intrinsic subprogram is used in the implementation of the
14722 library package @code{GNAT.Source_Info}. The only useful use of the
14723 intrinsic import in this case is the one in this unit, so an
14724 application program should simply call the function
14725 @code{GNAT.Source_Info.Compilation_Time} to obtain the time of
14726 the current compilation (in local time format HH:MM:SS).
14727
14728 @node Enclosing_Entity
14729 @section Enclosing_Entity
14730 @cindex Enclosing_Entity
14731 @noindent
14732 This intrinsic subprogram is used in the implementation of the
14733 library package @code{GNAT.Source_Info}. The only useful use of the
14734 intrinsic import in this case is the one in this unit, so an
14735 application program should simply call the function
14736 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
14737 the current subprogram, package, task, entry, or protected subprogram.
14738
14739 @node Exception_Information
14740 @section Exception_Information
14741 @cindex Exception_Information'
14742 @noindent
14743 This intrinsic subprogram is used in the implementation of the
14744 library package @code{GNAT.Current_Exception}. The only useful
14745 use of the intrinsic import in this case is the one in this unit,
14746 so an application program should simply call the function
14747 @code{GNAT.Current_Exception.Exception_Information} to obtain
14748 the exception information associated with the current exception.
14749
14750 @node Exception_Message
14751 @section Exception_Message
14752 @cindex Exception_Message
14753 @noindent
14754 This intrinsic subprogram is used in the implementation of the
14755 library package @code{GNAT.Current_Exception}. The only useful
14756 use of the intrinsic import in this case is the one in this unit,
14757 so an application program should simply call the function
14758 @code{GNAT.Current_Exception.Exception_Message} to obtain
14759 the message associated with the current exception.
14760
14761 @node Exception_Name
14762 @section Exception_Name
14763 @cindex Exception_Name
14764 @noindent
14765 This intrinsic subprogram is used in the implementation of the
14766 library package @code{GNAT.Current_Exception}. The only useful
14767 use of the intrinsic import in this case is the one in this unit,
14768 so an application program should simply call the function
14769 @code{GNAT.Current_Exception.Exception_Name} to obtain
14770 the name of the current exception.
14771
14772 @node File
14773 @section File
14774 @cindex File
14775 @noindent
14776 This intrinsic subprogram is used in the implementation of the
14777 library package @code{GNAT.Source_Info}. The only useful use of the
14778 intrinsic import in this case is the one in this unit, so an
14779 application program should simply call the function
14780 @code{GNAT.Source_Info.File} to obtain the name of the current
14781 file.
14782
14783 @node Line
14784 @section Line
14785 @cindex Line
14786 @noindent
14787 This intrinsic subprogram is used in the implementation of the
14788 library package @code{GNAT.Source_Info}. The only useful use of the
14789 intrinsic import in this case is the one in this unit, so an
14790 application program should simply call the function
14791 @code{GNAT.Source_Info.Line} to obtain the number of the current
14792 source line.
14793
14794 @node Shifts and Rotates
14795 @section Shifts and Rotates
14796 @cindex Shift_Left
14797 @cindex Shift_Right
14798 @cindex Shift_Right_Arithmetic
14799 @cindex Rotate_Left
14800 @cindex Rotate_Right
14801 @noindent
14802 In standard Ada, the shift and rotate functions are available only
14803 for the predefined modular types in package @code{Interfaces}. However, in
14804 GNAT it is possible to define these functions for any integer
14805 type (signed or modular), as in this example:
14806
14807 @smallexample @c ada
14808 function Shift_Left
14809 (Value : T;
14810 Amount : Natural) return T;
14811 @end smallexample
14812
14813 @noindent
14814 The function name must be one of
14815 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
14816 Rotate_Right. T must be an integer type. T'Size must be
14817 8, 16, 32 or 64 bits; if T is modular, the modulus
14818 must be 2**8, 2**16, 2**32 or 2**64.
14819 The result type must be the same as the type of @code{Value}.
14820 The shift amount must be Natural.
14821 The formal parameter names can be anything.
14822
14823 A more convenient way of providing these shift operators is to use
14824 the Provide_Shift_Operators pragma, which provides the function declarations
14825 and corresponding pragma Import's for all five shift functions.
14826
14827 @node Source_Location
14828 @section Source_Location
14829 @cindex Source_Location
14830 @noindent
14831 This intrinsic subprogram is used in the implementation of the
14832 library routine @code{GNAT.Source_Info}. The only useful use of the
14833 intrinsic import in this case is the one in this unit, so an
14834 application program should simply call the function
14835 @code{GNAT.Source_Info.Source_Location} to obtain the current
14836 source file location.
14837
14838 @node Representation Clauses and Pragmas
14839 @chapter Representation Clauses and Pragmas
14840 @cindex Representation Clauses
14841
14842 @menu
14843 * Alignment Clauses::
14844 * Size Clauses::
14845 * Storage_Size Clauses::
14846 * Size of Variant Record Objects::
14847 * Biased Representation ::
14848 * Value_Size and Object_Size Clauses::
14849 * Component_Size Clauses::
14850 * Bit_Order Clauses::
14851 * Effect of Bit_Order on Byte Ordering::
14852 * Pragma Pack for Arrays::
14853 * Pragma Pack for Records::
14854 * Record Representation Clauses::
14855 * Handling of Records with Holes::
14856 * Enumeration Clauses::
14857 * Address Clauses::
14858 * Effect of Convention on Representation::
14859 * Conventions and Anonymous Access Types::
14860 * Determining the Representations chosen by GNAT::
14861 @end menu
14862
14863 @noindent
14864 @cindex Representation Clause
14865 @cindex Representation Pragma
14866 @cindex Pragma, representation
14867 This section describes the representation clauses accepted by GNAT, and
14868 their effect on the representation of corresponding data objects.
14869
14870 GNAT fully implements Annex C (Systems Programming). This means that all
14871 the implementation advice sections in chapter 13 are fully implemented.
14872 However, these sections only require a minimal level of support for
14873 representation clauses. GNAT provides much more extensive capabilities,
14874 and this section describes the additional capabilities provided.
14875
14876 @node Alignment Clauses
14877 @section Alignment Clauses
14878 @cindex Alignment Clause
14879
14880 @noindent
14881 GNAT requires that all alignment clauses specify a power of 2, and all
14882 default alignments are always a power of 2. The default alignment
14883 values are as follows:
14884
14885 @itemize @bullet
14886 @item @emph{Primitive Types}.
14887 For primitive types, the alignment is the minimum of the actual size of
14888 objects of the type divided by @code{Storage_Unit},
14889 and the maximum alignment supported by the target.
14890 (This maximum alignment is given by the GNAT-specific attribute
14891 @code{Standard'Maximum_Alignment}; see @ref{Attribute Maximum_Alignment}.)
14892 @cindex @code{Maximum_Alignment} attribute
14893 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
14894 default alignment will be 8 on any target that supports alignments
14895 this large, but on some targets, the maximum alignment may be smaller
14896 than 8, in which case objects of type @code{Long_Float} will be maximally
14897 aligned.
14898
14899 @item @emph{Arrays}.
14900 For arrays, the alignment is equal to the alignment of the component type
14901 for the normal case where no packing or component size is given. If the
14902 array is packed, and the packing is effective (see separate section on
14903 packed arrays), then the alignment will be one for long packed arrays,
14904 or arrays whose length is not known at compile time. For short packed
14905 arrays, which are handled internally as modular types, the alignment
14906 will be as described for primitive types, e.g.@: a packed array of length
14907 31 bits will have an object size of four bytes, and an alignment of 4.
14908
14909 @item @emph{Records}.
14910 For the normal non-packed case, the alignment of a record is equal to
14911 the maximum alignment of any of its components. For tagged records, this
14912 includes the implicit access type used for the tag. If a pragma @code{Pack}
14913 is used and all components are packable (see separate section on pragma
14914 @code{Pack}), then the resulting alignment is 1, unless the layout of the
14915 record makes it profitable to increase it.
14916
14917 A special case is when:
14918 @itemize @bullet
14919 @item
14920 the size of the record is given explicitly, or a
14921 full record representation clause is given, and
14922 @item
14923 the size of the record is 2, 4, or 8 bytes.
14924 @end itemize
14925 @noindent
14926 In this case, an alignment is chosen to match the
14927 size of the record. For example, if we have:
14928
14929 @smallexample @c ada
14930 type Small is record
14931 A, B : Character;
14932 end record;
14933 for Small'Size use 16;
14934 @end smallexample
14935
14936 @noindent
14937 then the default alignment of the record type @code{Small} is 2, not 1. This
14938 leads to more efficient code when the record is treated as a unit, and also
14939 allows the type to specified as @code{Atomic} on architectures requiring
14940 strict alignment.
14941
14942 @end itemize
14943
14944 @noindent
14945 An alignment clause may specify a larger alignment than the default value
14946 up to some maximum value dependent on the target (obtainable by using the
14947 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
14948 a smaller alignment than the default value for enumeration, integer and
14949 fixed point types, as well as for record types, for example
14950
14951 @smallexample @c ada
14952 type V is record
14953 A : Integer;
14954 end record;
14955
14956 for V'alignment use 1;
14957 @end smallexample
14958
14959 @noindent
14960 @cindex Alignment, default
14961 The default alignment for the type @code{V} is 4, as a result of the
14962 Integer field in the record, but it is permissible, as shown, to
14963 override the default alignment of the record with a smaller value.
14964
14965 @cindex Alignment, subtypes
14966 Note that according to the Ada standard, an alignment clause applies only
14967 to the first named subtype. If additional subtypes are declared, then the
14968 compiler is allowed to choose any alignment it likes, and there is no way
14969 to control this choice. Consider:
14970
14971 @smallexample @c ada
14972 type R is range 1 .. 10_000;
14973 for R'Alignment use 1;
14974 subtype RS is R range 1 .. 1000;
14975 @end smallexample
14976
14977 @noindent
14978 The alignment clause specifies an alignment of 1 for the first named subtype
14979 @code{R} but this does not necessarily apply to @code{RS}. When writing
14980 portable Ada code, you should avoid writing code that explicitly or
14981 implicitly relies on the alignment of such subtypes.
14982
14983 For the GNAT compiler, if an explicit alignment clause is given, this
14984 value is also used for any subsequent subtypes. So for GNAT, in the
14985 above example, you can count on the alignment of @code{RS} being 1. But this
14986 assumption is non-portable, and other compilers may choose different
14987 alignments for the subtype @code{RS}.
14988
14989 @node Size Clauses
14990 @section Size Clauses
14991 @cindex Size Clause
14992
14993 @noindent
14994 The default size for a type @code{T} is obtainable through the
14995 language-defined attribute @code{T'Size} and also through the
14996 equivalent GNAT-defined attribute @code{T'Value_Size}.
14997 For objects of type @code{T}, GNAT will generally increase the type size
14998 so that the object size (obtainable through the GNAT-defined attribute
14999 @code{T'Object_Size})
15000 is a multiple of @code{T'Alignment * Storage_Unit}.
15001 For example
15002
15003 @smallexample @c ada
15004 type Smallint is range 1 .. 6;
15005
15006 type Rec is record
15007 Y1 : integer;
15008 Y2 : boolean;
15009 end record;
15010 @end smallexample
15011
15012 @noindent
15013 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
15014 as specified by the RM rules,
15015 but objects of this type will have a size of 8
15016 (@code{Smallint'Object_Size} = 8),
15017 since objects by default occupy an integral number
15018 of storage units. On some targets, notably older
15019 versions of the Digital Alpha, the size of stand
15020 alone objects of this type may be 32, reflecting
15021 the inability of the hardware to do byte load/stores.
15022
15023 Similarly, the size of type @code{Rec} is 40 bits
15024 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
15025 the alignment is 4, so objects of this type will have
15026 their size increased to 64 bits so that it is a multiple
15027 of the alignment (in bits). This decision is
15028 in accordance with the specific Implementation Advice in RM 13.3(43):
15029
15030 @quotation
15031 A @code{Size} clause should be supported for an object if the specified
15032 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
15033 to a size in storage elements that is a multiple of the object's
15034 @code{Alignment} (if the @code{Alignment} is nonzero).
15035 @end quotation
15036
15037 @noindent
15038 An explicit size clause may be used to override the default size by
15039 increasing it. For example, if we have:
15040
15041 @smallexample @c ada
15042 type My_Boolean is new Boolean;
15043 for My_Boolean'Size use 32;
15044 @end smallexample
15045
15046 @noindent
15047 then values of this type will always be 32 bits long. In the case of
15048 discrete types, the size can be increased up to 64 bits, with the effect
15049 that the entire specified field is used to hold the value, sign- or
15050 zero-extended as appropriate. If more than 64 bits is specified, then
15051 padding space is allocated after the value, and a warning is issued that
15052 there are unused bits.
15053
15054 Similarly the size of records and arrays may be increased, and the effect
15055 is to add padding bits after the value. This also causes a warning message
15056 to be generated.
15057
15058 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
15059 Size in bits, this corresponds to an object of size 256 megabytes (minus
15060 one). This limitation is true on all targets. The reason for this
15061 limitation is that it improves the quality of the code in many cases
15062 if it is known that a Size value can be accommodated in an object of
15063 type Integer.
15064
15065 @node Storage_Size Clauses
15066 @section Storage_Size Clauses
15067 @cindex Storage_Size Clause
15068
15069 @noindent
15070 For tasks, the @code{Storage_Size} clause specifies the amount of space
15071 to be allocated for the task stack. This cannot be extended, and if the
15072 stack is exhausted, then @code{Storage_Error} will be raised (if stack
15073 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
15074 or a @code{Storage_Size} pragma in the task definition to set the
15075 appropriate required size. A useful technique is to include in every
15076 task definition a pragma of the form:
15077
15078 @smallexample @c ada
15079 pragma Storage_Size (Default_Stack_Size);
15080 @end smallexample
15081
15082 @noindent
15083 Then @code{Default_Stack_Size} can be defined in a global package, and
15084 modified as required. Any tasks requiring stack sizes different from the
15085 default can have an appropriate alternative reference in the pragma.
15086
15087 You can also use the @option{-d} binder switch to modify the default stack
15088 size.
15089
15090 For access types, the @code{Storage_Size} clause specifies the maximum
15091 space available for allocation of objects of the type. If this space is
15092 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
15093 In the case where the access type is declared local to a subprogram, the
15094 use of a @code{Storage_Size} clause triggers automatic use of a special
15095 predefined storage pool (@code{System.Pool_Size}) that ensures that all
15096 space for the pool is automatically reclaimed on exit from the scope in
15097 which the type is declared.
15098
15099 A special case recognized by the compiler is the specification of a
15100 @code{Storage_Size} of zero for an access type. This means that no
15101 items can be allocated from the pool, and this is recognized at compile
15102 time, and all the overhead normally associated with maintaining a fixed
15103 size storage pool is eliminated. Consider the following example:
15104
15105 @smallexample @c ada
15106 procedure p is
15107 type R is array (Natural) of Character;
15108 type P is access all R;
15109 for P'Storage_Size use 0;
15110 -- Above access type intended only for interfacing purposes
15111
15112 y : P;
15113
15114 procedure g (m : P);
15115 pragma Import (C, g);
15116
15117 -- @dots{}
15118
15119 begin
15120 -- @dots{}
15121 y := new R;
15122 end;
15123 @end smallexample
15124
15125 @noindent
15126 As indicated in this example, these dummy storage pools are often useful in
15127 connection with interfacing where no object will ever be allocated. If you
15128 compile the above example, you get the warning:
15129
15130 @smallexample
15131 p.adb:16:09: warning: allocation from empty storage pool
15132 p.adb:16:09: warning: Storage_Error will be raised at run time
15133 @end smallexample
15134
15135 @noindent
15136 Of course in practice, there will not be any explicit allocators in the
15137 case of such an access declaration.
15138
15139 @node Size of Variant Record Objects
15140 @section Size of Variant Record Objects
15141 @cindex Size, variant record objects
15142 @cindex Variant record objects, size
15143
15144 @noindent
15145 In the case of variant record objects, there is a question whether Size gives
15146 information about a particular variant, or the maximum size required
15147 for any variant. Consider the following program
15148
15149 @smallexample @c ada
15150 with Text_IO; use Text_IO;
15151 procedure q is
15152 type R1 (A : Boolean := False) is record
15153 case A is
15154 when True => X : Character;
15155 when False => null;
15156 end case;
15157 end record;
15158
15159 V1 : R1 (False);
15160 V2 : R1;
15161
15162 begin
15163 Put_Line (Integer'Image (V1'Size));
15164 Put_Line (Integer'Image (V2'Size));
15165 end q;
15166 @end smallexample
15167
15168 @noindent
15169 Here we are dealing with a variant record, where the True variant
15170 requires 16 bits, and the False variant requires 8 bits.
15171 In the above example, both V1 and V2 contain the False variant,
15172 which is only 8 bits long. However, the result of running the
15173 program is:
15174
15175 @smallexample
15176 8
15177 16
15178 @end smallexample
15179
15180 @noindent
15181 The reason for the difference here is that the discriminant value of
15182 V1 is fixed, and will always be False. It is not possible to assign
15183 a True variant value to V1, therefore 8 bits is sufficient. On the
15184 other hand, in the case of V2, the initial discriminant value is
15185 False (from the default), but it is possible to assign a True
15186 variant value to V2, therefore 16 bits must be allocated for V2
15187 in the general case, even fewer bits may be needed at any particular
15188 point during the program execution.
15189
15190 As can be seen from the output of this program, the @code{'Size}
15191 attribute applied to such an object in GNAT gives the actual allocated
15192 size of the variable, which is the largest size of any of the variants.
15193 The Ada Reference Manual is not completely clear on what choice should
15194 be made here, but the GNAT behavior seems most consistent with the
15195 language in the RM@.
15196
15197 In some cases, it may be desirable to obtain the size of the current
15198 variant, rather than the size of the largest variant. This can be
15199 achieved in GNAT by making use of the fact that in the case of a
15200 subprogram parameter, GNAT does indeed return the size of the current
15201 variant (because a subprogram has no way of knowing how much space
15202 is actually allocated for the actual).
15203
15204 Consider the following modified version of the above program:
15205
15206 @smallexample @c ada
15207 with Text_IO; use Text_IO;
15208 procedure q is
15209 type R1 (A : Boolean := False) is record
15210 case A is
15211 when True => X : Character;
15212 when False => null;
15213 end case;
15214 end record;
15215
15216 V2 : R1;
15217
15218 function Size (V : R1) return Integer is
15219 begin
15220 return V'Size;
15221 end Size;
15222
15223 begin
15224 Put_Line (Integer'Image (V2'Size));
15225 Put_Line (Integer'IMage (Size (V2)));
15226 V2 := (True, 'x');
15227 Put_Line (Integer'Image (V2'Size));
15228 Put_Line (Integer'IMage (Size (V2)));
15229 end q;
15230 @end smallexample
15231
15232 @noindent
15233 The output from this program is
15234
15235 @smallexample
15236 16
15237 8
15238 16
15239 16
15240 @end smallexample
15241
15242 @noindent
15243 Here we see that while the @code{'Size} attribute always returns
15244 the maximum size, regardless of the current variant value, the
15245 @code{Size} function does indeed return the size of the current
15246 variant value.
15247
15248 @node Biased Representation
15249 @section Biased Representation
15250 @cindex Size for biased representation
15251 @cindex Biased representation
15252
15253 @noindent
15254 In the case of scalars with a range starting at other than zero, it is
15255 possible in some cases to specify a size smaller than the default minimum
15256 value, and in such cases, GNAT uses an unsigned biased representation,
15257 in which zero is used to represent the lower bound, and successive values
15258 represent successive values of the type.
15259
15260 For example, suppose we have the declaration:
15261
15262 @smallexample @c ada
15263 type Small is range -7 .. -4;
15264 for Small'Size use 2;
15265 @end smallexample
15266
15267 @noindent
15268 Although the default size of type @code{Small} is 4, the @code{Size}
15269 clause is accepted by GNAT and results in the following representation
15270 scheme:
15271
15272 @smallexample
15273 -7 is represented as 2#00#
15274 -6 is represented as 2#01#
15275 -5 is represented as 2#10#
15276 -4 is represented as 2#11#
15277 @end smallexample
15278
15279 @noindent
15280 Biased representation is only used if the specified @code{Size} clause
15281 cannot be accepted in any other manner. These reduced sizes that force
15282 biased representation can be used for all discrete types except for
15283 enumeration types for which a representation clause is given.
15284
15285 @node Value_Size and Object_Size Clauses
15286 @section Value_Size and Object_Size Clauses
15287 @findex Value_Size
15288 @findex Object_Size
15289 @cindex Size, of objects
15290
15291 @noindent
15292 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
15293 number of bits required to hold values of type @code{T}.
15294 Although this interpretation was allowed in Ada 83, it was not required,
15295 and this requirement in practice can cause some significant difficulties.
15296 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
15297 However, in Ada 95 and Ada 2005,
15298 @code{Natural'Size} is
15299 typically 31. This means that code may change in behavior when moving
15300 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
15301
15302 @smallexample @c ada
15303 type Rec is record;
15304 A : Natural;
15305 B : Natural;
15306 end record;
15307
15308 for Rec use record
15309 at 0 range 0 .. Natural'Size - 1;
15310 at 0 range Natural'Size .. 2 * Natural'Size - 1;
15311 end record;
15312 @end smallexample
15313
15314 @noindent
15315 In the above code, since the typical size of @code{Natural} objects
15316 is 32 bits and @code{Natural'Size} is 31, the above code can cause
15317 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
15318 there are cases where the fact that the object size can exceed the
15319 size of the type causes surprises.
15320
15321 To help get around this problem GNAT provides two implementation
15322 defined attributes, @code{Value_Size} and @code{Object_Size}. When
15323 applied to a type, these attributes yield the size of the type
15324 (corresponding to the RM defined size attribute), and the size of
15325 objects of the type respectively.
15326
15327 The @code{Object_Size} is used for determining the default size of
15328 objects and components. This size value can be referred to using the
15329 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
15330 the basis of the determination of the size. The backend is free to
15331 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
15332 character might be stored in 32 bits on a machine with no efficient
15333 byte access instructions such as the Alpha.
15334
15335 The default rules for the value of @code{Object_Size} for
15336 discrete types are as follows:
15337
15338 @itemize @bullet
15339 @item
15340 The @code{Object_Size} for base subtypes reflect the natural hardware
15341 size in bits (run the compiler with @option{-gnatS} to find those values
15342 for numeric types). Enumeration types and fixed-point base subtypes have
15343 8, 16, 32 or 64 bits for this size, depending on the range of values
15344 to be stored.
15345
15346 @item
15347 The @code{Object_Size} of a subtype is the same as the
15348 @code{Object_Size} of
15349 the type from which it is obtained.
15350
15351 @item
15352 The @code{Object_Size} of a derived base type is copied from the parent
15353 base type, and the @code{Object_Size} of a derived first subtype is copied
15354 from the parent first subtype.
15355 @end itemize
15356
15357 @noindent
15358 The @code{Value_Size} attribute
15359 is the (minimum) number of bits required to store a value
15360 of the type.
15361 This value is used to determine how tightly to pack
15362 records or arrays with components of this type, and also affects
15363 the semantics of unchecked conversion (unchecked conversions where
15364 the @code{Value_Size} values differ generate a warning, and are potentially
15365 target dependent).
15366
15367 The default rules for the value of @code{Value_Size} are as follows:
15368
15369 @itemize @bullet
15370 @item
15371 The @code{Value_Size} for a base subtype is the minimum number of bits
15372 required to store all values of the type (including the sign bit
15373 only if negative values are possible).
15374
15375 @item
15376 If a subtype statically matches the first subtype of a given type, then it has
15377 by default the same @code{Value_Size} as the first subtype. This is a
15378 consequence of RM 13.1(14) (``if two subtypes statically match,
15379 then their subtype-specific aspects are the same''.)
15380
15381 @item
15382 All other subtypes have a @code{Value_Size} corresponding to the minimum
15383 number of bits required to store all values of the subtype. For
15384 dynamic bounds, it is assumed that the value can range down or up
15385 to the corresponding bound of the ancestor
15386 @end itemize
15387
15388 @noindent
15389 The RM defined attribute @code{Size} corresponds to the
15390 @code{Value_Size} attribute.
15391
15392 The @code{Size} attribute may be defined for a first-named subtype. This sets
15393 the @code{Value_Size} of
15394 the first-named subtype to the given value, and the
15395 @code{Object_Size} of this first-named subtype to the given value padded up
15396 to an appropriate boundary. It is a consequence of the default rules
15397 above that this @code{Object_Size} will apply to all further subtypes. On the
15398 other hand, @code{Value_Size} is affected only for the first subtype, any
15399 dynamic subtypes obtained from it directly, and any statically matching
15400 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
15401
15402 @code{Value_Size} and
15403 @code{Object_Size} may be explicitly set for any subtype using
15404 an attribute definition clause. Note that the use of these attributes
15405 can cause the RM 13.1(14) rule to be violated. If two access types
15406 reference aliased objects whose subtypes have differing @code{Object_Size}
15407 values as a result of explicit attribute definition clauses, then it
15408 is illegal to convert from one access subtype to the other. For a more
15409 complete description of this additional legality rule, see the
15410 description of the @code{Object_Size} attribute.
15411
15412 At the implementation level, Esize stores the Object_Size and the
15413 RM_Size field stores the @code{Value_Size} (and hence the value of the
15414 @code{Size} attribute,
15415 which, as noted above, is equivalent to @code{Value_Size}).
15416
15417 To get a feel for the difference, consider the following examples (note
15418 that in each case the base is @code{Short_Short_Integer} with a size of 8):
15419
15420 @smallexample
15421 Object_Size Value_Size
15422
15423 type x1 is range 0 .. 5; 8 3
15424
15425 type x2 is range 0 .. 5;
15426 for x2'size use 12; 16 12
15427
15428 subtype x3 is x2 range 0 .. 3; 16 2
15429
15430 subtype x4 is x2'base range 0 .. 10; 8 4
15431
15432 subtype x5 is x2 range 0 .. dynamic; 16 3*
15433
15434 subtype x6 is x2'base range 0 .. dynamic; 8 3*
15435
15436 @end smallexample
15437
15438 @noindent
15439 Note: the entries marked ``3*'' are not actually specified by the Ada
15440 Reference Manual, but it seems in the spirit of the RM rules to allocate
15441 the minimum number of bits (here 3, given the range for @code{x2})
15442 known to be large enough to hold the given range of values.
15443
15444 So far, so good, but GNAT has to obey the RM rules, so the question is
15445 under what conditions must the RM @code{Size} be used.
15446 The following is a list
15447 of the occasions on which the RM @code{Size} must be used:
15448
15449 @itemize @bullet
15450 @item
15451 Component size for packed arrays or records
15452
15453 @item
15454 Value of the attribute @code{Size} for a type
15455
15456 @item
15457 Warning about sizes not matching for unchecked conversion
15458 @end itemize
15459
15460 @noindent
15461 For record types, the @code{Object_Size} is always a multiple of the
15462 alignment of the type (this is true for all types). In some cases the
15463 @code{Value_Size} can be smaller. Consider:
15464
15465 @smallexample
15466 type R is record
15467 X : Integer;
15468 Y : Character;
15469 end record;
15470 @end smallexample
15471
15472 @noindent
15473 On a typical 32-bit architecture, the X component will be four bytes, and
15474 require four-byte alignment, and the Y component will be one byte. In this
15475 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
15476 required to store a value of this type, and for example, it is permissible
15477 to have a component of type R in an outer array whose component size is
15478 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
15479 since it must be rounded up so that this value is a multiple of the
15480 alignment (4 bytes = 32 bits).
15481
15482 @noindent
15483 For all other types, the @code{Object_Size}
15484 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
15485 Only @code{Size} may be specified for such types.
15486
15487 Note that @code{Value_Size} can be used to force biased representation
15488 for a particular subtype. Consider this example:
15489
15490 @smallexample
15491 type R is (A, B, C, D, E, F);
15492 subtype RAB is R range A .. B;
15493 subtype REF is R range E .. F;
15494 @end smallexample
15495
15496 @noindent
15497 By default, @code{RAB}
15498 has a size of 1 (sufficient to accommodate the representation
15499 of @code{A} and @code{B}, 0 and 1), and @code{REF}
15500 has a size of 3 (sufficient to accommodate the representation
15501 of @code{E} and @code{F}, 4 and 5). But if we add the
15502 following @code{Value_Size} attribute definition clause:
15503
15504 @smallexample
15505 for REF'Value_Size use 1;
15506 @end smallexample
15507
15508 @noindent
15509 then biased representation is forced for @code{REF},
15510 and 0 will represent @code{E} and 1 will represent @code{F}.
15511 A warning is issued when a @code{Value_Size} attribute
15512 definition clause forces biased representation. This
15513 warning can be turned off using @code{-gnatw.B}.
15514
15515 @node Component_Size Clauses
15516 @section Component_Size Clauses
15517 @cindex Component_Size Clause
15518
15519 @noindent
15520 Normally, the value specified in a component size clause must be consistent
15521 with the subtype of the array component with regard to size and alignment.
15522 In other words, the value specified must be at least equal to the size
15523 of this subtype, and must be a multiple of the alignment value.
15524
15525 In addition, component size clauses are allowed which cause the array
15526 to be packed, by specifying a smaller value. A first case is for
15527 component size values in the range 1 through 63. The value specified
15528 must not be smaller than the Size of the subtype. GNAT will accurately
15529 honor all packing requests in this range. For example, if we have:
15530
15531 @smallexample @c ada
15532 type r is array (1 .. 8) of Natural;
15533 for r'Component_Size use 31;
15534 @end smallexample
15535
15536 @noindent
15537 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
15538 Of course access to the components of such an array is considerably
15539 less efficient than if the natural component size of 32 is used.
15540 A second case is when the subtype of the component is a record type
15541 padded because of its default alignment. For example, if we have:
15542
15543 @smallexample @c ada
15544 type r is record
15545 i : Integer;
15546 j : Integer;
15547 b : Boolean;
15548 end record;
15549
15550 type a is array (1 .. 8) of r;
15551 for a'Component_Size use 72;
15552 @end smallexample
15553
15554 @noindent
15555 then the resulting array has a length of 72 bytes, instead of 96 bytes
15556 if the alignment of the record (4) was obeyed.
15557
15558 Note that there is no point in giving both a component size clause
15559 and a pragma Pack for the same array type. if such duplicate
15560 clauses are given, the pragma Pack will be ignored.
15561
15562 @node Bit_Order Clauses
15563 @section Bit_Order Clauses
15564 @cindex Bit_Order Clause
15565 @cindex bit ordering
15566 @cindex ordering, of bits
15567
15568 @noindent
15569 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
15570 attribute. The specification may either correspond to the default bit
15571 order for the target, in which case the specification has no effect and
15572 places no additional restrictions, or it may be for the non-standard
15573 setting (that is the opposite of the default).
15574
15575 In the case where the non-standard value is specified, the effect is
15576 to renumber bits within each byte, but the ordering of bytes is not
15577 affected. There are certain
15578 restrictions placed on component clauses as follows:
15579
15580 @itemize @bullet
15581
15582 @item Components fitting within a single storage unit.
15583 @noindent
15584 These are unrestricted, and the effect is merely to renumber bits. For
15585 example if we are on a little-endian machine with @code{Low_Order_First}
15586 being the default, then the following two declarations have exactly
15587 the same effect:
15588
15589 @smallexample @c ada
15590 type R1 is record
15591 A : Boolean;
15592 B : Integer range 1 .. 120;
15593 end record;
15594
15595 for R1 use record
15596 A at 0 range 0 .. 0;
15597 B at 0 range 1 .. 7;
15598 end record;
15599
15600 type R2 is record
15601 A : Boolean;
15602 B : Integer range 1 .. 120;
15603 end record;
15604
15605 for R2'Bit_Order use High_Order_First;
15606
15607 for R2 use record
15608 A at 0 range 7 .. 7;
15609 B at 0 range 0 .. 6;
15610 end record;
15611 @end smallexample
15612
15613 @noindent
15614 The useful application here is to write the second declaration with the
15615 @code{Bit_Order} attribute definition clause, and know that it will be treated
15616 the same, regardless of whether the target is little-endian or big-endian.
15617
15618 @item Components occupying an integral number of bytes.
15619 @noindent
15620 These are components that exactly fit in two or more bytes. Such component
15621 declarations are allowed, but have no effect, since it is important to realize
15622 that the @code{Bit_Order} specification does not affect the ordering of bytes.
15623 In particular, the following attempt at getting an endian-independent integer
15624 does not work:
15625
15626 @smallexample @c ada
15627 type R2 is record
15628 A : Integer;
15629 end record;
15630
15631 for R2'Bit_Order use High_Order_First;
15632
15633 for R2 use record
15634 A at 0 range 0 .. 31;
15635 end record;
15636 @end smallexample
15637
15638 @noindent
15639 This declaration will result in a little-endian integer on a
15640 little-endian machine, and a big-endian integer on a big-endian machine.
15641 If byte flipping is required for interoperability between big- and
15642 little-endian machines, this must be explicitly programmed. This capability
15643 is not provided by @code{Bit_Order}.
15644
15645 @item Components that are positioned across byte boundaries
15646 @noindent
15647 but do not occupy an integral number of bytes. Given that bytes are not
15648 reordered, such fields would occupy a non-contiguous sequence of bits
15649 in memory, requiring non-trivial code to reassemble. They are for this
15650 reason not permitted, and any component clause specifying such a layout
15651 will be flagged as illegal by GNAT@.
15652
15653 @end itemize
15654
15655 @noindent
15656 Since the misconception that Bit_Order automatically deals with all
15657 endian-related incompatibilities is a common one, the specification of
15658 a component field that is an integral number of bytes will always
15659 generate a warning. This warning may be suppressed using @code{pragma
15660 Warnings (Off)} if desired. The following section contains additional
15661 details regarding the issue of byte ordering.
15662
15663 @node Effect of Bit_Order on Byte Ordering
15664 @section Effect of Bit_Order on Byte Ordering
15665 @cindex byte ordering
15666 @cindex ordering, of bytes
15667
15668 @noindent
15669 In this section we will review the effect of the @code{Bit_Order} attribute
15670 definition clause on byte ordering. Briefly, it has no effect at all, but
15671 a detailed example will be helpful. Before giving this
15672 example, let us review the precise
15673 definition of the effect of defining @code{Bit_Order}. The effect of a
15674 non-standard bit order is described in section 15.5.3 of the Ada
15675 Reference Manual:
15676
15677 @quotation
15678 2 A bit ordering is a method of interpreting the meaning of
15679 the storage place attributes.
15680 @end quotation
15681
15682 @noindent
15683 To understand the precise definition of storage place attributes in
15684 this context, we visit section 13.5.1 of the manual:
15685
15686 @quotation
15687 13 A record_representation_clause (without the mod_clause)
15688 specifies the layout. The storage place attributes (see 13.5.2)
15689 are taken from the values of the position, first_bit, and last_bit
15690 expressions after normalizing those values so that first_bit is
15691 less than Storage_Unit.
15692 @end quotation
15693
15694 @noindent
15695 The critical point here is that storage places are taken from
15696 the values after normalization, not before. So the @code{Bit_Order}
15697 interpretation applies to normalized values. The interpretation
15698 is described in the later part of the 15.5.3 paragraph:
15699
15700 @quotation
15701 2 A bit ordering is a method of interpreting the meaning of
15702 the storage place attributes. High_Order_First (known in the
15703 vernacular as ``big endian'') means that the first bit of a
15704 storage element (bit 0) is the most significant bit (interpreting
15705 the sequence of bits that represent a component as an unsigned
15706 integer value). Low_Order_First (known in the vernacular as
15707 ``little endian'') means the opposite: the first bit is the
15708 least significant.
15709 @end quotation
15710
15711 @noindent
15712 Note that the numbering is with respect to the bits of a storage
15713 unit. In other words, the specification affects only the numbering
15714 of bits within a single storage unit.
15715
15716 We can make the effect clearer by giving an example.
15717
15718 Suppose that we have an external device which presents two bytes, the first
15719 byte presented, which is the first (low addressed byte) of the two byte
15720 record is called Master, and the second byte is called Slave.
15721
15722 The left most (most significant bit is called Control for each byte, and
15723 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
15724 (least significant) bit.
15725
15726 On a big-endian machine, we can write the following representation clause
15727
15728 @smallexample @c ada
15729 type Data is record
15730 Master_Control : Bit;
15731 Master_V1 : Bit;
15732 Master_V2 : Bit;
15733 Master_V3 : Bit;
15734 Master_V4 : Bit;
15735 Master_V5 : Bit;
15736 Master_V6 : Bit;
15737 Master_V7 : Bit;
15738 Slave_Control : Bit;
15739 Slave_V1 : Bit;
15740 Slave_V2 : Bit;
15741 Slave_V3 : Bit;
15742 Slave_V4 : Bit;
15743 Slave_V5 : Bit;
15744 Slave_V6 : Bit;
15745 Slave_V7 : Bit;
15746 end record;
15747
15748 for Data use record
15749 Master_Control at 0 range 0 .. 0;
15750 Master_V1 at 0 range 1 .. 1;
15751 Master_V2 at 0 range 2 .. 2;
15752 Master_V3 at 0 range 3 .. 3;
15753 Master_V4 at 0 range 4 .. 4;
15754 Master_V5 at 0 range 5 .. 5;
15755 Master_V6 at 0 range 6 .. 6;
15756 Master_V7 at 0 range 7 .. 7;
15757 Slave_Control at 1 range 0 .. 0;
15758 Slave_V1 at 1 range 1 .. 1;
15759 Slave_V2 at 1 range 2 .. 2;
15760 Slave_V3 at 1 range 3 .. 3;
15761 Slave_V4 at 1 range 4 .. 4;
15762 Slave_V5 at 1 range 5 .. 5;
15763 Slave_V6 at 1 range 6 .. 6;
15764 Slave_V7 at 1 range 7 .. 7;
15765 end record;
15766 @end smallexample
15767
15768 @noindent
15769 Now if we move this to a little endian machine, then the bit ordering within
15770 the byte is backwards, so we have to rewrite the record rep clause as:
15771
15772 @smallexample @c ada
15773 for Data use record
15774 Master_Control at 0 range 7 .. 7;
15775 Master_V1 at 0 range 6 .. 6;
15776 Master_V2 at 0 range 5 .. 5;
15777 Master_V3 at 0 range 4 .. 4;
15778 Master_V4 at 0 range 3 .. 3;
15779 Master_V5 at 0 range 2 .. 2;
15780 Master_V6 at 0 range 1 .. 1;
15781 Master_V7 at 0 range 0 .. 0;
15782 Slave_Control at 1 range 7 .. 7;
15783 Slave_V1 at 1 range 6 .. 6;
15784 Slave_V2 at 1 range 5 .. 5;
15785 Slave_V3 at 1 range 4 .. 4;
15786 Slave_V4 at 1 range 3 .. 3;
15787 Slave_V5 at 1 range 2 .. 2;
15788 Slave_V6 at 1 range 1 .. 1;
15789 Slave_V7 at 1 range 0 .. 0;
15790 end record;
15791 @end smallexample
15792
15793 @noindent
15794 It is a nuisance to have to rewrite the clause, especially if
15795 the code has to be maintained on both machines. However,
15796 this is a case that we can handle with the
15797 @code{Bit_Order} attribute if it is implemented.
15798 Note that the implementation is not required on byte addressed
15799 machines, but it is indeed implemented in GNAT.
15800 This means that we can simply use the
15801 first record clause, together with the declaration
15802
15803 @smallexample @c ada
15804 for Data'Bit_Order use High_Order_First;
15805 @end smallexample
15806
15807 @noindent
15808 and the effect is what is desired, namely the layout is exactly the same,
15809 independent of whether the code is compiled on a big-endian or little-endian
15810 machine.
15811
15812 The important point to understand is that byte ordering is not affected.
15813 A @code{Bit_Order} attribute definition never affects which byte a field
15814 ends up in, only where it ends up in that byte.
15815 To make this clear, let us rewrite the record rep clause of the previous
15816 example as:
15817
15818 @smallexample @c ada
15819 for Data'Bit_Order use High_Order_First;
15820 for Data use record
15821 Master_Control at 0 range 0 .. 0;
15822 Master_V1 at 0 range 1 .. 1;
15823 Master_V2 at 0 range 2 .. 2;
15824 Master_V3 at 0 range 3 .. 3;
15825 Master_V4 at 0 range 4 .. 4;
15826 Master_V5 at 0 range 5 .. 5;
15827 Master_V6 at 0 range 6 .. 6;
15828 Master_V7 at 0 range 7 .. 7;
15829 Slave_Control at 0 range 8 .. 8;
15830 Slave_V1 at 0 range 9 .. 9;
15831 Slave_V2 at 0 range 10 .. 10;
15832 Slave_V3 at 0 range 11 .. 11;
15833 Slave_V4 at 0 range 12 .. 12;
15834 Slave_V5 at 0 range 13 .. 13;
15835 Slave_V6 at 0 range 14 .. 14;
15836 Slave_V7 at 0 range 15 .. 15;
15837 end record;
15838 @end smallexample
15839
15840 @noindent
15841 This is exactly equivalent to saying (a repeat of the first example):
15842
15843 @smallexample @c ada
15844 for Data'Bit_Order use High_Order_First;
15845 for Data use record
15846 Master_Control at 0 range 0 .. 0;
15847 Master_V1 at 0 range 1 .. 1;
15848 Master_V2 at 0 range 2 .. 2;
15849 Master_V3 at 0 range 3 .. 3;
15850 Master_V4 at 0 range 4 .. 4;
15851 Master_V5 at 0 range 5 .. 5;
15852 Master_V6 at 0 range 6 .. 6;
15853 Master_V7 at 0 range 7 .. 7;
15854 Slave_Control at 1 range 0 .. 0;
15855 Slave_V1 at 1 range 1 .. 1;
15856 Slave_V2 at 1 range 2 .. 2;
15857 Slave_V3 at 1 range 3 .. 3;
15858 Slave_V4 at 1 range 4 .. 4;
15859 Slave_V5 at 1 range 5 .. 5;
15860 Slave_V6 at 1 range 6 .. 6;
15861 Slave_V7 at 1 range 7 .. 7;
15862 end record;
15863 @end smallexample
15864
15865 @noindent
15866 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
15867 field. The storage place attributes are obtained by normalizing the
15868 values given so that the @code{First_Bit} value is less than 8. After
15869 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
15870 we specified in the other case.
15871
15872 Now one might expect that the @code{Bit_Order} attribute might affect
15873 bit numbering within the entire record component (two bytes in this
15874 case, thus affecting which byte fields end up in), but that is not
15875 the way this feature is defined, it only affects numbering of bits,
15876 not which byte they end up in.
15877
15878 Consequently it never makes sense to specify a starting bit number
15879 greater than 7 (for a byte addressable field) if an attribute
15880 definition for @code{Bit_Order} has been given, and indeed it
15881 may be actively confusing to specify such a value, so the compiler
15882 generates a warning for such usage.
15883
15884 If you do need to control byte ordering then appropriate conditional
15885 values must be used. If in our example, the slave byte came first on
15886 some machines we might write:
15887
15888 @smallexample @c ada
15889 Master_Byte_First constant Boolean := @dots{};
15890
15891 Master_Byte : constant Natural :=
15892 1 - Boolean'Pos (Master_Byte_First);
15893 Slave_Byte : constant Natural :=
15894 Boolean'Pos (Master_Byte_First);
15895
15896 for Data'Bit_Order use High_Order_First;
15897 for Data use record
15898 Master_Control at Master_Byte range 0 .. 0;
15899 Master_V1 at Master_Byte range 1 .. 1;
15900 Master_V2 at Master_Byte range 2 .. 2;
15901 Master_V3 at Master_Byte range 3 .. 3;
15902 Master_V4 at Master_Byte range 4 .. 4;
15903 Master_V5 at Master_Byte range 5 .. 5;
15904 Master_V6 at Master_Byte range 6 .. 6;
15905 Master_V7 at Master_Byte range 7 .. 7;
15906 Slave_Control at Slave_Byte range 0 .. 0;
15907 Slave_V1 at Slave_Byte range 1 .. 1;
15908 Slave_V2 at Slave_Byte range 2 .. 2;
15909 Slave_V3 at Slave_Byte range 3 .. 3;
15910 Slave_V4 at Slave_Byte range 4 .. 4;
15911 Slave_V5 at Slave_Byte range 5 .. 5;
15912 Slave_V6 at Slave_Byte range 6 .. 6;
15913 Slave_V7 at Slave_Byte range 7 .. 7;
15914 end record;
15915 @end smallexample
15916
15917 @noindent
15918 Now to switch between machines, all that is necessary is
15919 to set the boolean constant @code{Master_Byte_First} in
15920 an appropriate manner.
15921
15922 @node Pragma Pack for Arrays
15923 @section Pragma Pack for Arrays
15924 @cindex Pragma Pack (for arrays)
15925
15926 @noindent
15927 Pragma @code{Pack} applied to an array has no effect unless the component type
15928 is packable. For a component type to be packable, it must be one of the
15929 following cases:
15930
15931 @itemize @bullet
15932 @item
15933 Any scalar type
15934 @item
15935 Any type whose size is specified with a size clause
15936 @item
15937 Any packed array type with a static size
15938 @item
15939 Any record type padded because of its default alignment
15940 @end itemize
15941
15942 @noindent
15943 For all these cases, if the component subtype size is in the range
15944 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
15945 component size were specified giving the component subtype size.
15946 For example if we have:
15947
15948 @smallexample @c ada
15949 type r is range 0 .. 17;
15950
15951 type ar is array (1 .. 8) of r;
15952 pragma Pack (ar);
15953 @end smallexample
15954
15955 @noindent
15956 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
15957 and the size of the array @code{ar} will be exactly 40 bits.
15958
15959 Note that in some cases this rather fierce approach to packing can produce
15960 unexpected effects. For example, in Ada 95 and Ada 2005,
15961 subtype @code{Natural} typically has a size of 31, meaning that if you
15962 pack an array of @code{Natural}, you get 31-bit
15963 close packing, which saves a few bits, but results in far less efficient
15964 access. Since many other Ada compilers will ignore such a packing request,
15965 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
15966 might not be what is intended. You can easily remove this warning by
15967 using an explicit @code{Component_Size} setting instead, which never generates
15968 a warning, since the intention of the programmer is clear in this case.
15969
15970 GNAT treats packed arrays in one of two ways. If the size of the array is
15971 known at compile time and is less than 64 bits, then internally the array
15972 is represented as a single modular type, of exactly the appropriate number
15973 of bits. If the length is greater than 63 bits, or is not known at compile
15974 time, then the packed array is represented as an array of bytes, and the
15975 length is always a multiple of 8 bits.
15976
15977 Note that to represent a packed array as a modular type, the alignment must
15978 be suitable for the modular type involved. For example, on typical machines
15979 a 32-bit packed array will be represented by a 32-bit modular integer with
15980 an alignment of four bytes. If you explicitly override the default alignment
15981 with an alignment clause that is too small, the modular representation
15982 cannot be used. For example, consider the following set of declarations:
15983
15984 @smallexample @c ada
15985 type R is range 1 .. 3;
15986 type S is array (1 .. 31) of R;
15987 for S'Component_Size use 2;
15988 for S'Size use 62;
15989 for S'Alignment use 1;
15990 @end smallexample
15991
15992 @noindent
15993 If the alignment clause were not present, then a 62-bit modular
15994 representation would be chosen (typically with an alignment of 4 or 8
15995 bytes depending on the target). But the default alignment is overridden
15996 with the explicit alignment clause. This means that the modular
15997 representation cannot be used, and instead the array of bytes
15998 representation must be used, meaning that the length must be a multiple
15999 of 8. Thus the above set of declarations will result in a diagnostic
16000 rejecting the size clause and noting that the minimum size allowed is 64.
16001
16002 @cindex Pragma Pack (for type Natural)
16003 @cindex Pragma Pack warning
16004
16005 One special case that is worth noting occurs when the base type of the
16006 component size is 8/16/32 and the subtype is one bit less. Notably this
16007 occurs with subtype @code{Natural}. Consider:
16008
16009 @smallexample @c ada
16010 type Arr is array (1 .. 32) of Natural;
16011 pragma Pack (Arr);
16012 @end smallexample
16013
16014 @noindent
16015 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
16016 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
16017 Ada 83 compilers did not attempt 31 bit packing.
16018
16019 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
16020 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
16021 substantial unintended performance penalty when porting legacy Ada 83 code.
16022 To help prevent this, GNAT generates a warning in such cases. If you really
16023 want 31 bit packing in a case like this, you can set the component size
16024 explicitly:
16025
16026 @smallexample @c ada
16027 type Arr is array (1 .. 32) of Natural;
16028 for Arr'Component_Size use 31;
16029 @end smallexample
16030
16031 @noindent
16032 Here 31-bit packing is achieved as required, and no warning is generated,
16033 since in this case the programmer intention is clear.
16034
16035 @node Pragma Pack for Records
16036 @section Pragma Pack for Records
16037 @cindex Pragma Pack (for records)
16038
16039 @noindent
16040 Pragma @code{Pack} applied to a record will pack the components to reduce
16041 wasted space from alignment gaps and by reducing the amount of space
16042 taken by components. We distinguish between @emph{packable} components and
16043 @emph{non-packable} components.
16044 Components of the following types are considered packable:
16045 @itemize @bullet
16046 @item
16047 Components of a primitive type are packable unless they are aliased
16048 or of an atomic type.
16049
16050 @item
16051 Small packed arrays, whose size does not exceed 64 bits, and where the
16052 size is statically known at compile time, are represented internally
16053 as modular integers, and so they are also packable.
16054
16055 @end itemize
16056
16057 @noindent
16058 All packable components occupy the exact number of bits corresponding to
16059 their @code{Size} value, and are packed with no padding bits, i.e.@: they
16060 can start on an arbitrary bit boundary.
16061
16062 All other types are non-packable, they occupy an integral number of
16063 storage units, and
16064 are placed at a boundary corresponding to their alignment requirements.
16065
16066 For example, consider the record
16067
16068 @smallexample @c ada
16069 type Rb1 is array (1 .. 13) of Boolean;
16070 pragma Pack (Rb1);
16071
16072 type Rb2 is array (1 .. 65) of Boolean;
16073 pragma Pack (Rb2);
16074
16075 type AF is new Float with Atomic;
16076
16077 type X2 is record
16078 L1 : Boolean;
16079 L2 : Duration;
16080 L3 : AF;
16081 L4 : Boolean;
16082 L5 : Rb1;
16083 L6 : Rb2;
16084 end record;
16085 pragma Pack (X2);
16086 @end smallexample
16087
16088 @noindent
16089 The representation for the record X2 is as follows:
16090
16091 @smallexample @c ada
16092 for X2'Size use 224;
16093 for X2 use record
16094 L1 at 0 range 0 .. 0;
16095 L2 at 0 range 1 .. 64;
16096 L3 at 12 range 0 .. 31;
16097 L4 at 16 range 0 .. 0;
16098 L5 at 16 range 1 .. 13;
16099 L6 at 18 range 0 .. 71;
16100 end record;
16101 @end smallexample
16102
16103 @noindent
16104 Studying this example, we see that the packable fields @code{L1}
16105 and @code{L2} are
16106 of length equal to their sizes, and placed at specific bit boundaries (and
16107 not byte boundaries) to
16108 eliminate padding. But @code{L3} is of a non-packable float type (because
16109 it is aliased), so it is on the next appropriate alignment boundary.
16110
16111 The next two fields are fully packable, so @code{L4} and @code{L5} are
16112 minimally packed with no gaps. However, type @code{Rb2} is a packed
16113 array that is longer than 64 bits, so it is itself non-packable. Thus
16114 the @code{L6} field is aligned to the next byte boundary, and takes an
16115 integral number of bytes, i.e.@: 72 bits.
16116
16117 @node Record Representation Clauses
16118 @section Record Representation Clauses
16119 @cindex Record Representation Clause
16120
16121 @noindent
16122 Record representation clauses may be given for all record types, including
16123 types obtained by record extension. Component clauses are allowed for any
16124 static component. The restrictions on component clauses depend on the type
16125 of the component.
16126
16127 @cindex Component Clause
16128 For all components of an elementary type, the only restriction on component
16129 clauses is that the size must be at least the 'Size value of the type
16130 (actually the Value_Size). There are no restrictions due to alignment,
16131 and such components may freely cross storage boundaries.
16132
16133 Packed arrays with a size up to and including 64 bits are represented
16134 internally using a modular type with the appropriate number of bits, and
16135 thus the same lack of restriction applies. For example, if you declare:
16136
16137 @smallexample @c ada
16138 type R is array (1 .. 49) of Boolean;
16139 pragma Pack (R);
16140 for R'Size use 49;
16141 @end smallexample
16142
16143 @noindent
16144 then a component clause for a component of type R may start on any
16145 specified bit boundary, and may specify a value of 49 bits or greater.
16146
16147 For packed bit arrays that are longer than 64 bits, there are two
16148 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
16149 including the important case of single bits or boolean values, then
16150 there are no limitations on placement of such components, and they
16151 may start and end at arbitrary bit boundaries.
16152
16153 If the component size is not a power of 2 (e.g.@: 3 or 5), then
16154 an array of this type longer than 64 bits must always be placed on
16155 on a storage unit (byte) boundary and occupy an integral number
16156 of storage units (bytes). Any component clause that does not
16157 meet this requirement will be rejected.
16158
16159 Any aliased component, or component of an aliased type, must
16160 have its normal alignment and size. A component clause that
16161 does not meet this requirement will be rejected.
16162
16163 The tag field of a tagged type always occupies an address sized field at
16164 the start of the record. No component clause may attempt to overlay this
16165 tag. When a tagged type appears as a component, the tag field must have
16166 proper alignment
16167
16168 In the case of a record extension T1, of a type T, no component clause applied
16169 to the type T1 can specify a storage location that would overlap the first
16170 T'Size bytes of the record.
16171
16172 For all other component types, including non-bit-packed arrays,
16173 the component can be placed at an arbitrary bit boundary,
16174 so for example, the following is permitted:
16175
16176 @smallexample @c ada
16177 type R is array (1 .. 10) of Boolean;
16178 for R'Size use 80;
16179
16180 type Q is record
16181 G, H : Boolean;
16182 L, M : R;
16183 end record;
16184
16185 for Q use record
16186 G at 0 range 0 .. 0;
16187 H at 0 range 1 .. 1;
16188 L at 0 range 2 .. 81;
16189 R at 0 range 82 .. 161;
16190 end record;
16191 @end smallexample
16192
16193 @noindent
16194 Note: the above rules apply to recent releases of GNAT 5.
16195 In GNAT 3, there are more severe restrictions on larger components.
16196 For non-primitive types, including packed arrays with a size greater than
16197 64 bits, component clauses must respect the alignment requirement of the
16198 type, in particular, always starting on a byte boundary, and the length
16199 must be a multiple of the storage unit.
16200
16201 @node Handling of Records with Holes
16202 @section Handling of Records with Holes
16203 @cindex Handling of Records with Holes
16204
16205 As a result of alignment considerations, records may contain "holes"
16206 or gaps
16207 which do not correspond to the data bits of any of the components.
16208 Record representation clauses can also result in holes in records.
16209
16210 GNAT does not attempt to clear these holes, so in record objects,
16211 they should be considered to hold undefined rubbish. The generated
16212 equality routine just tests components so does not access these
16213 undefined bits, and assignment and copy operations may or may not
16214 preserve the contents of these holes (for assignments, the holes
16215 in the target will in practice contain either the bits that are
16216 present in the holes in the source, or the bits that were present
16217 in the target before the assignment).
16218
16219 If it is necessary to ensure that holes in records have all zero
16220 bits, then record objects for which this initialization is desired
16221 should be explicitly set to all zero values using Unchecked_Conversion
16222 or address overlays. For example
16223
16224 @smallexample @c ada
16225 type HRec is record
16226 C : Character;
16227 I : Integer;
16228 end record;
16229 @end smallexample
16230
16231 @noindent
16232 On typical machines, integers need to be aligned on a four-byte
16233 boundary, resulting in three bytes of undefined rubbish following
16234 the 8-bit field for C. To ensure that the hole in a variable of
16235 type HRec is set to all zero bits,
16236 you could for example do:
16237
16238 @smallexample @c ada
16239 type Base is record
16240 Dummy1, Dummy2 : Integer := 0;
16241 end record;
16242
16243 BaseVar : Base;
16244 RealVar : Hrec;
16245 for RealVar'Address use BaseVar'Address;
16246 @end smallexample
16247
16248 @noindent
16249 Now the 8-bytes of the value of RealVar start out containing all zero
16250 bits. A safer approach is to just define dummy fields, avoiding the
16251 holes, as in:
16252
16253 @smallexample @c ada
16254 type HRec is record
16255 C : Character;
16256 Dummy1 : Short_Short_Integer := 0;
16257 Dummy2 : Short_Short_Integer := 0;
16258 Dummy3 : Short_Short_Integer := 0;
16259 I : Integer;
16260 end record;
16261 @end smallexample
16262
16263 @noindent
16264 And to make absolutely sure that the intent of this is followed, you
16265 can use representation clauses:
16266
16267 @smallexample @c ada
16268 for Hrec use record
16269 C at 0 range 0 .. 7;
16270 Dummy1 at 1 range 0 .. 7;
16271 Dummy2 at 2 range 0 .. 7;
16272 Dummy3 at 3 range 0 .. 7;
16273 I at 4 range 0 .. 31;
16274 end record;
16275 for Hrec'Size use 64;
16276 @end smallexample
16277
16278 @node Enumeration Clauses
16279 @section Enumeration Clauses
16280
16281 The only restriction on enumeration clauses is that the range of values
16282 must be representable. For the signed case, if one or more of the
16283 representation values are negative, all values must be in the range:
16284
16285 @smallexample @c ada
16286 System.Min_Int .. System.Max_Int
16287 @end smallexample
16288
16289 @noindent
16290 For the unsigned case, where all values are nonnegative, the values must
16291 be in the range:
16292
16293 @smallexample @c ada
16294 0 .. System.Max_Binary_Modulus;
16295 @end smallexample
16296
16297 @noindent
16298 A @emph{confirming} representation clause is one in which the values range
16299 from 0 in sequence, i.e.@: a clause that confirms the default representation
16300 for an enumeration type.
16301 Such a confirming representation
16302 is permitted by these rules, and is specially recognized by the compiler so
16303 that no extra overhead results from the use of such a clause.
16304
16305 If an array has an index type which is an enumeration type to which an
16306 enumeration clause has been applied, then the array is stored in a compact
16307 manner. Consider the declarations:
16308
16309 @smallexample @c ada
16310 type r is (A, B, C);
16311 for r use (A => 1, B => 5, C => 10);
16312 type t is array (r) of Character;
16313 @end smallexample
16314
16315 @noindent
16316 The array type t corresponds to a vector with exactly three elements and
16317 has a default size equal to @code{3*Character'Size}. This ensures efficient
16318 use of space, but means that accesses to elements of the array will incur
16319 the overhead of converting representation values to the corresponding
16320 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
16321
16322 @node Address Clauses
16323 @section Address Clauses
16324 @cindex Address Clause
16325
16326 The reference manual allows a general restriction on representation clauses,
16327 as found in RM 13.1(22):
16328
16329 @quotation
16330 An implementation need not support representation
16331 items containing nonstatic expressions, except that
16332 an implementation should support a representation item
16333 for a given entity if each nonstatic expression in the
16334 representation item is a name that statically denotes
16335 a constant declared before the entity.
16336 @end quotation
16337
16338 @noindent
16339 In practice this is applicable only to address clauses, since this is the
16340 only case in which a non-static expression is permitted by the syntax. As
16341 the AARM notes in sections 13.1 (22.a-22.h):
16342
16343 @display
16344 22.a Reason: This is to avoid the following sort of thing:
16345
16346 22.b X : Integer := F(@dots{});
16347 Y : Address := G(@dots{});
16348 for X'Address use Y;
16349
16350 22.c In the above, we have to evaluate the
16351 initialization expression for X before we
16352 know where to put the result. This seems
16353 like an unreasonable implementation burden.
16354
16355 22.d The above code should instead be written
16356 like this:
16357
16358 22.e Y : constant Address := G(@dots{});
16359 X : Integer := F(@dots{});
16360 for X'Address use Y;
16361
16362 22.f This allows the expression ``Y'' to be safely
16363 evaluated before X is created.
16364
16365 22.g The constant could be a formal parameter of mode in.
16366
16367 22.h An implementation can support other nonstatic
16368 expressions if it wants to. Expressions of type
16369 Address are hardly ever static, but their value
16370 might be known at compile time anyway in many
16371 cases.
16372 @end display
16373
16374 @noindent
16375 GNAT does indeed permit many additional cases of non-static expressions. In
16376 particular, if the type involved is elementary there are no restrictions
16377 (since in this case, holding a temporary copy of the initialization value,
16378 if one is present, is inexpensive). In addition, if there is no implicit or
16379 explicit initialization, then there are no restrictions. GNAT will reject
16380 only the case where all three of these conditions hold:
16381
16382 @itemize @bullet
16383
16384 @item
16385 The type of the item is non-elementary (e.g.@: a record or array).
16386
16387 @item
16388 There is explicit or implicit initialization required for the object.
16389 Note that access values are always implicitly initialized.
16390
16391 @item
16392 The address value is non-static. Here GNAT is more permissive than the
16393 RM, and allows the address value to be the address of a previously declared
16394 stand-alone variable, as long as it does not itself have an address clause.
16395
16396 @smallexample @c ada
16397 Anchor : Some_Initialized_Type;
16398 Overlay : Some_Initialized_Type;
16399 for Overlay'Address use Anchor'Address;
16400 @end smallexample
16401
16402 @noindent
16403 However, the prefix of the address clause cannot be an array component, or
16404 a component of a discriminated record.
16405
16406 @end itemize
16407
16408 @noindent
16409 As noted above in section 22.h, address values are typically non-static. In
16410 particular the To_Address function, even if applied to a literal value, is
16411 a non-static function call. To avoid this minor annoyance, GNAT provides
16412 the implementation defined attribute 'To_Address. The following two
16413 expressions have identical values:
16414
16415 @findex Attribute
16416 @findex To_Address
16417 @smallexample @c ada
16418 To_Address (16#1234_0000#)
16419 System'To_Address (16#1234_0000#);
16420 @end smallexample
16421
16422 @noindent
16423 except that the second form is considered to be a static expression, and
16424 thus when used as an address clause value is always permitted.
16425
16426 @noindent
16427 Additionally, GNAT treats as static an address clause that is an
16428 unchecked_conversion of a static integer value. This simplifies the porting
16429 of legacy code, and provides a portable equivalent to the GNAT attribute
16430 @code{To_Address}.
16431
16432 Another issue with address clauses is the interaction with alignment
16433 requirements. When an address clause is given for an object, the address
16434 value must be consistent with the alignment of the object (which is usually
16435 the same as the alignment of the type of the object). If an address clause
16436 is given that specifies an inappropriately aligned address value, then the
16437 program execution is erroneous.
16438
16439 Since this source of erroneous behavior can have unfortunate effects, GNAT
16440 checks (at compile time if possible, generating a warning, or at execution
16441 time with a run-time check) that the alignment is appropriate. If the
16442 run-time check fails, then @code{Program_Error} is raised. This run-time
16443 check is suppressed if range checks are suppressed, or if the special GNAT
16444 check Alignment_Check is suppressed, or if
16445 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
16446
16447 Finally, GNAT does not permit overlaying of objects of controlled types or
16448 composite types containing a controlled component. In most cases, the compiler
16449 can detect an attempt at such overlays and will generate a warning at compile
16450 time and a Program_Error exception at run time.
16451
16452 @findex Export
16453 An address clause cannot be given for an exported object. More
16454 understandably the real restriction is that objects with an address
16455 clause cannot be exported. This is because such variables are not
16456 defined by the Ada program, so there is no external object to export.
16457
16458 @findex Import
16459 It is permissible to give an address clause and a pragma Import for the
16460 same object. In this case, the variable is not really defined by the
16461 Ada program, so there is no external symbol to be linked. The link name
16462 and the external name are ignored in this case. The reason that we allow this
16463 combination is that it provides a useful idiom to avoid unwanted
16464 initializations on objects with address clauses.
16465
16466 When an address clause is given for an object that has implicit or
16467 explicit initialization, then by default initialization takes place. This
16468 means that the effect of the object declaration is to overwrite the
16469 memory at the specified address. This is almost always not what the
16470 programmer wants, so GNAT will output a warning:
16471
16472 @smallexample
16473 with System;
16474 package G is
16475 type R is record
16476 M : Integer := 0;
16477 end record;
16478
16479 Ext : R;
16480 for Ext'Address use System'To_Address (16#1234_1234#);
16481 |
16482 >>> warning: implicit initialization of "Ext" may
16483 modify overlaid storage
16484 >>> warning: use pragma Import for "Ext" to suppress
16485 initialization (RM B(24))
16486
16487 end G;
16488 @end smallexample
16489
16490 @noindent
16491 As indicated by the warning message, the solution is to use a (dummy) pragma
16492 Import to suppress this initialization. The pragma tell the compiler that the
16493 object is declared and initialized elsewhere. The following package compiles
16494 without warnings (and the initialization is suppressed):
16495
16496 @smallexample @c ada
16497 with System;
16498 package G is
16499 type R is record
16500 M : Integer := 0;
16501 end record;
16502
16503 Ext : R;
16504 for Ext'Address use System'To_Address (16#1234_1234#);
16505 pragma Import (Ada, Ext);
16506 end G;
16507 @end smallexample
16508
16509 @noindent
16510 A final issue with address clauses involves their use for overlaying
16511 variables, as in the following example:
16512 @cindex Overlaying of objects
16513
16514 @smallexample @c ada
16515 A : Integer;
16516 B : Integer;
16517 for B'Address use A'Address;
16518 @end smallexample
16519
16520 @noindent
16521 or alternatively, using the form recommended by the RM:
16522
16523 @smallexample @c ada
16524 A : Integer;
16525 Addr : constant Address := A'Address;
16526 B : Integer;
16527 for B'Address use Addr;
16528 @end smallexample
16529
16530 @noindent
16531 In both of these cases, @code{A}
16532 and @code{B} become aliased to one another via the
16533 address clause. This use of address clauses to overlay
16534 variables, achieving an effect similar to unchecked
16535 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
16536 the effect is implementation defined. Furthermore, the
16537 Ada RM specifically recommends that in a situation
16538 like this, @code{B} should be subject to the following
16539 implementation advice (RM 13.3(19)):
16540
16541 @quotation
16542 19 If the Address of an object is specified, or it is imported
16543 or exported, then the implementation should not perform
16544 optimizations based on assumptions of no aliases.
16545 @end quotation
16546
16547 @noindent
16548 GNAT follows this recommendation, and goes further by also applying
16549 this recommendation to the overlaid variable (@code{A}
16550 in the above example) in this case. This means that the overlay
16551 works "as expected", in that a modification to one of the variables
16552 will affect the value of the other.
16553
16554 Note that when address clause overlays are used in this way, there is an
16555 issue of unintentional initialization, as shown by this example:
16556
16557 @smallexample @c ada
16558 package Overwrite_Record is
16559 type R is record
16560 A : Character := 'C';
16561 B : Character := 'A';
16562 end record;
16563 X : Short_Integer := 3;
16564 Y : R;
16565 for Y'Address use X'Address;
16566 |
16567 >>> warning: default initialization of "Y" may
16568 modify "X", use pragma Import for "Y" to
16569 suppress initialization (RM B.1(24))
16570
16571 end Overwrite_Record;
16572 @end smallexample
16573
16574 @noindent
16575 Here the default initialization of @code{Y} will clobber the value
16576 of @code{X}, which justifies the warning. The warning notes that
16577 this effect can be eliminated by adding a @code{pragma Import}
16578 which suppresses the initialization:
16579
16580 @smallexample @c ada
16581 package Overwrite_Record is
16582 type R is record
16583 A : Character := 'C';
16584 B : Character := 'A';
16585 end record;
16586 X : Short_Integer := 3;
16587 Y : R;
16588 for Y'Address use X'Address;
16589 pragma Import (Ada, Y);
16590 end Overwrite_Record;
16591 @end smallexample
16592
16593 @noindent
16594 Note that the use of @code{pragma Initialize_Scalars} may cause variables to
16595 be initialized when they would not otherwise have been in the absence
16596 of the use of this pragma. This may cause an overlay to have this
16597 unintended clobbering effect. The compiler avoids this for scalar
16598 types, but not for composite objects (where in general the effect
16599 of @code{Initialize_Scalars} is part of the initialization routine
16600 for the composite object:
16601
16602 @smallexample @c ada
16603 pragma Initialize_Scalars;
16604 with Ada.Text_IO; use Ada.Text_IO;
16605 procedure Overwrite_Array is
16606 type Arr is array (1 .. 5) of Integer;
16607 X : Arr := (others => 1);
16608 A : Arr;
16609 for A'Address use X'Address;
16610 |
16611 >>> warning: default initialization of "A" may
16612 modify "X", use pragma Import for "A" to
16613 suppress initialization (RM B.1(24))
16614
16615 begin
16616 if X /= Arr'(others => 1) then
16617 Put_Line ("X was clobbered");
16618 else
16619 Put_Line ("X was not clobbered");
16620 end if;
16621 end Overwrite_Array;
16622 @end smallexample
16623
16624 @noindent
16625 The above program generates the warning as shown, and at execution
16626 time, prints @code{X was clobbered}. If the @code{pragma Import} is
16627 added as suggested:
16628
16629 @smallexample @c ada
16630 pragma Initialize_Scalars;
16631 with Ada.Text_IO; use Ada.Text_IO;
16632 procedure Overwrite_Array is
16633 type Arr is array (1 .. 5) of Integer;
16634 X : Arr := (others => 1);
16635 A : Arr;
16636 for A'Address use X'Address;
16637 pragma Import (Ada, A);
16638 begin
16639 if X /= Arr'(others => 1) then
16640 Put_Line ("X was clobbered");
16641 else
16642 Put_Line ("X was not clobbered");
16643 end if;
16644 end Overwrite_Array;
16645 @end smallexample
16646
16647 @noindent
16648 then the program compiles without the warning and when run will generate
16649 the output @code{X was not clobbered}.
16650
16651 @node Effect of Convention on Representation
16652 @section Effect of Convention on Representation
16653 @cindex Convention, effect on representation
16654
16655 @noindent
16656 Normally the specification of a foreign language convention for a type or
16657 an object has no effect on the chosen representation. In particular, the
16658 representation chosen for data in GNAT generally meets the standard system
16659 conventions, and for example records are laid out in a manner that is
16660 consistent with C@. This means that specifying convention C (for example)
16661 has no effect.
16662
16663 There are four exceptions to this general rule:
16664
16665 @itemize @bullet
16666
16667 @item Convention Fortran and array subtypes
16668 If pragma Convention Fortran is specified for an array subtype, then in
16669 accordance with the implementation advice in section 3.6.2(11) of the
16670 Ada Reference Manual, the array will be stored in a Fortran-compatible
16671 column-major manner, instead of the normal default row-major order.
16672
16673 @item Convention C and enumeration types
16674 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
16675 to accommodate all values of the type. For example, for the enumeration
16676 type declared by:
16677
16678 @smallexample @c ada
16679 type Color is (Red, Green, Blue);
16680 @end smallexample
16681
16682 @noindent
16683 8 bits is sufficient to store all values of the type, so by default, objects
16684 of type @code{Color} will be represented using 8 bits. However, normal C
16685 convention is to use 32 bits for all enum values in C, since enum values
16686 are essentially of type int. If pragma @code{Convention C} is specified for an
16687 Ada enumeration type, then the size is modified as necessary (usually to
16688 32 bits) to be consistent with the C convention for enum values.
16689
16690 Note that this treatment applies only to types. If Convention C is given for
16691 an enumeration object, where the enumeration type is not Convention C, then
16692 Object_Size bits are allocated. For example, for a normal enumeration type,
16693 with less than 256 elements, only 8 bits will be allocated for the object.
16694 Since this may be a surprise in terms of what C expects, GNAT will issue a
16695 warning in this situation. The warning can be suppressed by giving an explicit
16696 size clause specifying the desired size.
16697
16698 @item Convention C/Fortran and Boolean types
16699 In C, the usual convention for boolean values, that is values used for
16700 conditions, is that zero represents false, and nonzero values represent
16701 true. In Ada, the normal convention is that two specific values, typically
16702 0/1, are used to represent false/true respectively.
16703
16704 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
16705 value represents true).
16706
16707 To accommodate the Fortran and C conventions, if a pragma Convention specifies
16708 C or Fortran convention for a derived Boolean, as in the following example:
16709
16710 @smallexample @c ada
16711 type C_Switch is new Boolean;
16712 pragma Convention (C, C_Switch);
16713 @end smallexample
16714
16715 @noindent
16716 then the GNAT generated code will treat any nonzero value as true. For truth
16717 values generated by GNAT, the conventional value 1 will be used for True, but
16718 when one of these values is read, any nonzero value is treated as True.
16719
16720 @item Access types on OpenVMS
16721 For 64-bit OpenVMS systems, access types (other than those for unconstrained
16722 arrays) are 64-bits long. An exception to this rule is for the case of
16723 C-convention access types where there is no explicit size clause present (or
16724 inherited for derived types). In this case, GNAT chooses to make these
16725 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
16726 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
16727
16728 @end itemize
16729
16730 @node Conventions and Anonymous Access Types
16731 @section Conventions and Anonymous Access Types
16732 @cindex Anonymous access types
16733 @cindex Convention for anonymous access types
16734
16735 The RM is not entirely clear on convention handling in a number of cases,
16736 and in particular, it is not clear on the convention to be given to
16737 anonymous access types in general, and in particular what is to be
16738 done for the case of anonymous access-to-subprogram.
16739
16740 In GNAT, we decide that if an explicit Convention is applied
16741 to an object or component, and its type is such an anonymous type,
16742 then the convention will apply to this anonymous type as well. This
16743 seems to make sense since it is anomolous in any case to have a
16744 different convention for an object and its type, and there is clearly
16745 no way to explicitly specify a convention for an anonymous type, since
16746 it doesn't have a name to specify!
16747
16748 Furthermore, we decide that if a convention is applied to a record type,
16749 then this convention is inherited by any of its components that are of an
16750 anonymous access type which do not have an explicitly specified convention.
16751
16752 The following program shows these conventions in action:
16753
16754 @smallexample @c ada
16755 package ConvComp is
16756 type Foo is range 1 .. 10;
16757 type T1 is record
16758 A : access function (X : Foo) return Integer;
16759 B : Integer;
16760 end record;
16761 pragma Convention (C, T1);
16762
16763 type T2 is record
16764 A : access function (X : Foo) return Integer;
16765 pragma Convention (C, A);
16766 B : Integer;
16767 end record;
16768 pragma Convention (COBOL, T2);
16769
16770 type T3 is record
16771 A : access function (X : Foo) return Integer;
16772 pragma Convention (COBOL, A);
16773 B : Integer;
16774 end record;
16775 pragma Convention (C, T3);
16776
16777 type T4 is record
16778 A : access function (X : Foo) return Integer;
16779 B : Integer;
16780 end record;
16781 pragma Convention (COBOL, T4);
16782
16783 function F (X : Foo) return Integer;
16784 pragma Convention (C, F);
16785
16786 function F (X : Foo) return Integer is (13);
16787
16788 TV1 : T1 := (F'Access, 12); -- OK
16789 TV2 : T2 := (F'Access, 13); -- OK
16790
16791 TV3 : T3 := (F'Access, 13); -- ERROR
16792 |
16793 >>> subprogram "F" has wrong convention
16794 >>> does not match access to subprogram declared at line 17
16795 38. TV4 : T4 := (F'Access, 13); -- ERROR
16796 |
16797 >>> subprogram "F" has wrong convention
16798 >>> does not match access to subprogram declared at line 24
16799 39. end ConvComp;
16800 @end smallexample
16801
16802 @node Determining the Representations chosen by GNAT
16803 @section Determining the Representations chosen by GNAT
16804 @cindex Representation, determination of
16805 @cindex @option{-gnatR} switch
16806
16807 @noindent
16808 Although the descriptions in this section are intended to be complete, it is
16809 often easier to simply experiment to see what GNAT accepts and what the
16810 effect is on the layout of types and objects.
16811
16812 As required by the Ada RM, if a representation clause is not accepted, then
16813 it must be rejected as illegal by the compiler. However, when a
16814 representation clause or pragma is accepted, there can still be questions
16815 of what the compiler actually does. For example, if a partial record
16816 representation clause specifies the location of some components and not
16817 others, then where are the non-specified components placed? Or if pragma
16818 @code{Pack} is used on a record, then exactly where are the resulting
16819 fields placed? The section on pragma @code{Pack} in this chapter can be
16820 used to answer the second question, but it is often easier to just see
16821 what the compiler does.
16822
16823 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
16824 with this option, then the compiler will output information on the actual
16825 representations chosen, in a format similar to source representation
16826 clauses. For example, if we compile the package:
16827
16828 @smallexample @c ada
16829 package q is
16830 type r (x : boolean) is tagged record
16831 case x is
16832 when True => S : String (1 .. 100);
16833 when False => null;
16834 end case;
16835 end record;
16836
16837 type r2 is new r (false) with record
16838 y2 : integer;
16839 end record;
16840
16841 for r2 use record
16842 y2 at 16 range 0 .. 31;
16843 end record;
16844
16845 type x is record
16846 y : character;
16847 end record;
16848
16849 type x1 is array (1 .. 10) of x;
16850 for x1'component_size use 11;
16851
16852 type ia is access integer;
16853
16854 type Rb1 is array (1 .. 13) of Boolean;
16855 pragma Pack (rb1);
16856
16857 type Rb2 is array (1 .. 65) of Boolean;
16858 pragma Pack (rb2);
16859
16860 type x2 is record
16861 l1 : Boolean;
16862 l2 : Duration;
16863 l3 : Float;
16864 l4 : Boolean;
16865 l5 : Rb1;
16866 l6 : Rb2;
16867 end record;
16868 pragma Pack (x2);
16869 end q;
16870 @end smallexample
16871
16872 @noindent
16873 using the switch @option{-gnatR} we obtain the following output:
16874
16875 @smallexample
16876 Representation information for unit q
16877 -------------------------------------
16878
16879 for r'Size use ??;
16880 for r'Alignment use 4;
16881 for r use record
16882 x at 4 range 0 .. 7;
16883 _tag at 0 range 0 .. 31;
16884 s at 5 range 0 .. 799;
16885 end record;
16886
16887 for r2'Size use 160;
16888 for r2'Alignment use 4;
16889 for r2 use record
16890 x at 4 range 0 .. 7;
16891 _tag at 0 range 0 .. 31;
16892 _parent at 0 range 0 .. 63;
16893 y2 at 16 range 0 .. 31;
16894 end record;
16895
16896 for x'Size use 8;
16897 for x'Alignment use 1;
16898 for x use record
16899 y at 0 range 0 .. 7;
16900 end record;
16901
16902 for x1'Size use 112;
16903 for x1'Alignment use 1;
16904 for x1'Component_Size use 11;
16905
16906 for rb1'Size use 13;
16907 for rb1'Alignment use 2;
16908 for rb1'Component_Size use 1;
16909
16910 for rb2'Size use 72;
16911 for rb2'Alignment use 1;
16912 for rb2'Component_Size use 1;
16913
16914 for x2'Size use 224;
16915 for x2'Alignment use 4;
16916 for x2 use record
16917 l1 at 0 range 0 .. 0;
16918 l2 at 0 range 1 .. 64;
16919 l3 at 12 range 0 .. 31;
16920 l4 at 16 range 0 .. 0;
16921 l5 at 16 range 1 .. 13;
16922 l6 at 18 range 0 .. 71;
16923 end record;
16924 @end smallexample
16925
16926 @noindent
16927 The Size values are actually the Object_Size, i.e.@: the default size that
16928 will be allocated for objects of the type.
16929 The ?? size for type r indicates that we have a variant record, and the
16930 actual size of objects will depend on the discriminant value.
16931
16932 The Alignment values show the actual alignment chosen by the compiler
16933 for each record or array type.
16934
16935 The record representation clause for type r shows where all fields
16936 are placed, including the compiler generated tag field (whose location
16937 cannot be controlled by the programmer).
16938
16939 The record representation clause for the type extension r2 shows all the
16940 fields present, including the parent field, which is a copy of the fields
16941 of the parent type of r2, i.e.@: r1.
16942
16943 The component size and size clauses for types rb1 and rb2 show
16944 the exact effect of pragma @code{Pack} on these arrays, and the record
16945 representation clause for type x2 shows how pragma @code{Pack} affects
16946 this record type.
16947
16948 In some cases, it may be useful to cut and paste the representation clauses
16949 generated by the compiler into the original source to fix and guarantee
16950 the actual representation to be used.
16951
16952 @node Standard Library Routines
16953 @chapter Standard Library Routines
16954
16955 @noindent
16956 The Ada Reference Manual contains in Annex A a full description of an
16957 extensive set of standard library routines that can be used in any Ada
16958 program, and which must be provided by all Ada compilers. They are
16959 analogous to the standard C library used by C programs.
16960
16961 GNAT implements all of the facilities described in annex A, and for most
16962 purposes the description in the Ada Reference Manual, or appropriate Ada
16963 text book, will be sufficient for making use of these facilities.
16964
16965 In the case of the input-output facilities,
16966 @xref{The Implementation of Standard I/O},
16967 gives details on exactly how GNAT interfaces to the
16968 file system. For the remaining packages, the Ada Reference Manual
16969 should be sufficient. The following is a list of the packages included,
16970 together with a brief description of the functionality that is provided.
16971
16972 For completeness, references are included to other predefined library
16973 routines defined in other sections of the Ada Reference Manual (these are
16974 cross-indexed from Annex A). For further details see the relevant
16975 package declarations in the run-time library. In particular, a few units
16976 are not implemented, as marked by the presence of pragma Unimplemented_Unit,
16977 and in this case the package declaration contains comments explaining why
16978 the unit is not implemented.
16979
16980 @table @code
16981 @item Ada (A.2)
16982 This is a parent package for all the standard library packages. It is
16983 usually included implicitly in your program, and itself contains no
16984 useful data or routines.
16985
16986 @item Ada.Assertions (11.4.2)
16987 @code{Assertions} provides the @code{Assert} subprograms, and also
16988 the declaration of the @code{Assertion_Error} exception.
16989
16990 @item Ada.Asynchronous_Task_Control (D.11)
16991 @code{Asynchronous_Task_Control} provides low level facilities for task
16992 synchronization. It is typically not implemented. See package spec for details.
16993
16994 @item Ada.Calendar (9.6)
16995 @code{Calendar} provides time of day access, and routines for
16996 manipulating times and durations.
16997
16998 @item Ada.Calendar.Arithmetic (9.6.1)
16999 This package provides additional arithmetic
17000 operations for @code{Calendar}.
17001
17002 @item Ada.Calendar.Formatting (9.6.1)
17003 This package provides formatting operations for @code{Calendar}.
17004
17005 @item Ada.Calendar.Time_Zones (9.6.1)
17006 This package provides additional @code{Calendar} facilities
17007 for handling time zones.
17008
17009 @item Ada.Characters (A.3.1)
17010 This is a dummy parent package that contains no useful entities
17011
17012 @item Ada.Characters.Conversions (A.3.2)
17013 This package provides character conversion functions.
17014
17015 @item Ada.Characters.Handling (A.3.2)
17016 This package provides some basic character handling capabilities,
17017 including classification functions for classes of characters (e.g.@: test
17018 for letters, or digits).
17019
17020 @item Ada.Characters.Latin_1 (A.3.3)
17021 This package includes a complete set of definitions of the characters
17022 that appear in type CHARACTER@. It is useful for writing programs that
17023 will run in international environments. For example, if you want an
17024 upper case E with an acute accent in a string, it is often better to use
17025 the definition of @code{UC_E_Acute} in this package. Then your program
17026 will print in an understandable manner even if your environment does not
17027 support these extended characters.
17028
17029 @item Ada.Command_Line (A.15)
17030 This package provides access to the command line parameters and the name
17031 of the current program (analogous to the use of @code{argc} and @code{argv}
17032 in C), and also allows the exit status for the program to be set in a
17033 system-independent manner.
17034
17035 @item Ada.Complex_Text_IO (G.1.3)
17036 This package provides text input and output of complex numbers.
17037
17038 @item Ada.Containers (A.18.1)
17039 A top level package providing a few basic definitions used by all the
17040 following specific child packages that provide specific kinds of
17041 containers.
17042
17043 @item Ada.Containers.Bounded_Priority_Queues (A.18.31)
17044
17045 @item Ada.Containers.Bounded_Synchronized_Queues (A.18.29)
17046
17047 @item Ada.Containers.Doubly_Linked_Lists (A.18.3)
17048
17049 @item Ada.Containers.Generic_Array_Sort (A.18.26)
17050
17051 @item Ada.Containers.Generic_Constrained_Array_Sort (A.18.26)
17052
17053 @item Ada.Containers.Generic_Sort (A.18.26)
17054
17055 @item Ada.Containers.Hashed_Maps (A.18.5)
17056
17057 @item Ada.Containers.Hashed_Sets (A.18.8)
17058
17059 @item Ada.Containers.Indefinite_Doubly_Linked_Lists (A.18.12)
17060
17061 @item Ada.Containers.Indefinite_Hashed_Maps (A.18.13)
17062
17063 @item Ada.Containers.Indefinite_Hashed_Sets (A.18.15)
17064
17065 @item Ada.Containers.Indefinite_Holders (A.18.18)
17066
17067 @item Ada.Containers.Indefinite_Multiway_Trees (A.18.17)
17068
17069 @item Ada.Containers.Indefinite_Ordered_Maps (A.18.14)
17070
17071 @item Ada.Containers.Indefinite_Ordered_Sets (A.18.16)
17072
17073 @item Ada.Containers.Indefinite_Vectors (A.18.11)
17074
17075 @item Ada.Containers.Multiway_Trees (A.18.10)
17076
17077 @item Ada.Containers.Ordered_Maps (A.18.6)
17078
17079 @item Ada.Containers.Ordered_Sets (A.18.9)
17080
17081 @item Ada.Containers.Synchronized_Queue_Interfaces (A.18.27)
17082
17083 @item Ada.Containers.Unbounded_Priority_Queues (A.18.30)
17084
17085 @item Ada.Containers.Unbounded_Synchronized_Queues (A.18.28)
17086
17087 @item Ada.Containers.Vectors (A.18.2)
17088
17089 @item Ada.Directories (A.16)
17090 This package provides operations on directories.
17091
17092 @item Ada.Directories.Hierarchical_File_Names (A.16.1)
17093 This package provides additional directory operations handling
17094 hiearchical file names.
17095
17096 @item Ada.Directories.Information (A.16)
17097 This is an implementation defined package for additional directory
17098 operations, which is not implemented in GNAT.
17099
17100 @item Ada.Decimal (F.2)
17101 This package provides constants describing the range of decimal numbers
17102 implemented, and also a decimal divide routine (analogous to the COBOL
17103 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
17104
17105 @item Ada.Direct_IO (A.8.4)
17106 This package provides input-output using a model of a set of records of
17107 fixed-length, containing an arbitrary definite Ada type, indexed by an
17108 integer record number.
17109
17110 @item Ada.Dispatching (D.2.1)
17111 A parent package containing definitions for task dispatching operations.
17112
17113 @item Ada.Dispatching.EDF (D.2.6)
17114 Not implemented in GNAT.
17115
17116 @item Ada.Dispatching.Non_Preemptive (D.2.4)
17117 Not implemented in GNAT.
17118
17119 @item Ada.Dispatching.Round_Robin (D.2.5)
17120 Not implemented in GNAT.
17121
17122 @item Ada.Dynamic_Priorities (D.5)
17123 This package allows the priorities of a task to be adjusted dynamically
17124 as the task is running.
17125
17126 @item Ada.Environment_Variables (A.17)
17127 This package provides facilities for accessing environment variables.
17128
17129 @item Ada.Exceptions (11.4.1)
17130 This package provides additional information on exceptions, and also
17131 contains facilities for treating exceptions as data objects, and raising
17132 exceptions with associated messages.
17133
17134 @item Ada.Execution_Time (D.14)
17135 Not implemented in GNAT.
17136
17137 @item Ada.Execution_Time.Group_Budgets (D.14.2)
17138 Not implemented in GNAT.
17139
17140 @item Ada.Execution_Time.Timers (D.14.1)'
17141 Not implemented in GNAT.
17142
17143 @item Ada.Finalization (7.6)
17144 This package contains the declarations and subprograms to support the
17145 use of controlled types, providing for automatic initialization and
17146 finalization (analogous to the constructors and destructors of C++).
17147
17148 @item Ada.Float_Text_IO (A.10.9)
17149 A library level instantiation of Text_IO.Float_IO for type Float.
17150
17151 @item Ada.Float_Wide_Text_IO (A.10.9)
17152 A library level instantiation of Wide_Text_IO.Float_IO for type Float.
17153
17154 @item Ada.Float_Wide_Wide_Text_IO (A.10.9)
17155 A library level instantiation of Wide_Wide_Text_IO.Float_IO for type Float.
17156
17157 @item Ada.Integer_Text_IO (A.10.9)
17158 A library level instantiation of Text_IO.Integer_IO for type Integer.
17159
17160 @item Ada.Integer_Wide_Text_IO (A.10.9)
17161 A library level instantiation of Wide_Text_IO.Integer_IO for type Integer.
17162
17163 @item Ada.Integer_Wide_Wide_Text_IO (A.10.9)
17164 A library level instantiation of Wide_Wide_Text_IO.Integer_IO for type Integer.
17165
17166 @item Ada.Interrupts (C.3.2)
17167 This package provides facilities for interfacing to interrupts, which
17168 includes the set of signals or conditions that can be raised and
17169 recognized as interrupts.
17170
17171 @item Ada.Interrupts.Names (C.3.2)
17172 This package provides the set of interrupt names (actually signal
17173 or condition names) that can be handled by GNAT@.
17174
17175 @item Ada.IO_Exceptions (A.13)
17176 This package defines the set of exceptions that can be raised by use of
17177 the standard IO packages.
17178
17179 @item Ada.Iterator_Interfaces (5.5.1)
17180 This package provides a generic interface to generalized iterators.
17181
17182 @item Ada.Locales (A.19)
17183 This package provides declarations providing information (Language
17184 and Country) about the current locale.
17185
17186 @item Ada.Numerics
17187 This package contains some standard constants and exceptions used
17188 throughout the numerics packages. Note that the constants pi and e are
17189 defined here, and it is better to use these definitions than rolling
17190 your own.
17191
17192 @item Ada.Numerics.Complex_Arrays (G.3.2)
17193 Provides operations on arrays of complex numbers.
17194
17195 @item Ada.Numerics.Complex_Elementary_Functions
17196 Provides the implementation of standard elementary functions (such as
17197 log and trigonometric functions) operating on complex numbers using the
17198 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
17199 created by the package @code{Numerics.Complex_Types}.
17200
17201 @item Ada.Numerics.Complex_Types
17202 This is a predefined instantiation of
17203 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
17204 build the type @code{Complex} and @code{Imaginary}.
17205
17206 @item Ada.Numerics.Discrete_Random
17207 This generic package provides a random number generator suitable for generating
17208 uniformly distributed values of a specified discrete subtype.
17209
17210 @item Ada.Numerics.Float_Random
17211 This package provides a random number generator suitable for generating
17212 uniformly distributed floating point values in the unit interval.
17213
17214 @item Ada.Numerics.Generic_Complex_Elementary_Functions
17215 This is a generic version of the package that provides the
17216 implementation of standard elementary functions (such as log and
17217 trigonometric functions) for an arbitrary complex type.
17218
17219 The following predefined instantiations of this package are provided:
17220
17221 @table @code
17222 @item Short_Float
17223 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
17224 @item Float
17225 @code{Ada.Numerics.Complex_Elementary_Functions}
17226 @item Long_Float
17227 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
17228 @end table
17229
17230 @item Ada.Numerics.Generic_Complex_Types
17231 This is a generic package that allows the creation of complex types,
17232 with associated complex arithmetic operations.
17233
17234 The following predefined instantiations of this package exist
17235 @table @code
17236 @item Short_Float
17237 @code{Ada.Numerics.Short_Complex_Complex_Types}
17238 @item Float
17239 @code{Ada.Numerics.Complex_Complex_Types}
17240 @item Long_Float
17241 @code{Ada.Numerics.Long_Complex_Complex_Types}
17242 @end table
17243
17244 @item Ada.Numerics.Generic_Elementary_Functions
17245 This is a generic package that provides the implementation of standard
17246 elementary functions (such as log an trigonometric functions) for an
17247 arbitrary float type.
17248
17249 The following predefined instantiations of this package exist
17250
17251 @table @code
17252 @item Short_Float
17253 @code{Ada.Numerics.Short_Elementary_Functions}
17254 @item Float
17255 @code{Ada.Numerics.Elementary_Functions}
17256 @item Long_Float
17257 @code{Ada.Numerics.Long_Elementary_Functions}
17258 @end table
17259
17260 @item Ada.Numerics.Generic_Real_Arrays (G.3.1)
17261 Generic operations on arrays of reals
17262
17263 @item Ada.Numerics.Real_Arrays (G.3.1)
17264 Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).
17265
17266 @item Ada.Real_Time (D.8)
17267 This package provides facilities similar to those of @code{Calendar}, but
17268 operating with a finer clock suitable for real time control. Note that
17269 annex D requires that there be no backward clock jumps, and GNAT generally
17270 guarantees this behavior, but of course if the external clock on which
17271 the GNAT runtime depends is deliberately reset by some external event,
17272 then such a backward jump may occur.
17273
17274 @item Ada.Real_Time.Timing_Events (D.15)
17275 Not implemented in GNAT.
17276
17277 @item Ada.Sequential_IO (A.8.1)
17278 This package provides input-output facilities for sequential files,
17279 which can contain a sequence of values of a single type, which can be
17280 any Ada type, including indefinite (unconstrained) types.
17281
17282 @item Ada.Storage_IO (A.9)
17283 This package provides a facility for mapping arbitrary Ada types to and
17284 from a storage buffer. It is primarily intended for the creation of new
17285 IO packages.
17286
17287 @item Ada.Streams (13.13.1)
17288 This is a generic package that provides the basic support for the
17289 concept of streams as used by the stream attributes (@code{Input},
17290 @code{Output}, @code{Read} and @code{Write}).
17291
17292 @item Ada.Streams.Stream_IO (A.12.1)
17293 This package is a specialization of the type @code{Streams} defined in
17294 package @code{Streams} together with a set of operations providing
17295 Stream_IO capability. The Stream_IO model permits both random and
17296 sequential access to a file which can contain an arbitrary set of values
17297 of one or more Ada types.
17298
17299 @item Ada.Strings (A.4.1)
17300 This package provides some basic constants used by the string handling
17301 packages.
17302
17303 @item Ada.Strings.Bounded (A.4.4)
17304 This package provides facilities for handling variable length
17305 strings. The bounded model requires a maximum length. It is thus
17306 somewhat more limited than the unbounded model, but avoids the use of
17307 dynamic allocation or finalization.
17308
17309 @item Ada.Strings.Bounded.Equal_Case_Insensitive (A.4.10)
17310 Provides case-insensitive comparisons of bounded strings
17311
17312 @item Ada.Strings.Bounded.Hash (A.4.9)
17313 This package provides a generic hash function for bounded strings
17314
17315 @item Ada.Strings.Bounded.Hash_Case_Insensitive (A.4.9)
17316 This package provides a generic hash function for bounded strings that
17317 converts the string to be hashed to lower case.
17318
17319 @item Ada.Strings.Bounded.Less_Case_Insensitive (A.4.10)
17320 This package provides a comparison function for bounded strings that works
17321 in a case insensitive manner by converting to lower case before the comparison.
17322
17323 @item Ada.Strings.Fixed (A.4.3)
17324 This package provides facilities for handling fixed length strings.
17325
17326 @item Ada.Strings.Fixed.Equal_Case_Insensitive (A.4.10)
17327 This package provides an equality function for fixed strings that compares
17328 the strings after converting both to lower case.
17329
17330 @item Ada.Strings.Fixed.Hash_Case_Insensitive (A.4.9)
17331 This package provides a case insensitive hash function for fixed strings that
17332 converts the string to lower case before computing the hash.
17333
17334 @item Ada.Strings.Fixed.Less_Case_Insensitive (A.4.10)
17335 This package provides a comparison function for fixed strings that works
17336 in a case insensitive manner by converting to lower case before the comparison.
17337
17338 Ada.Strings.Hash (A.4.9)
17339 This package provides a hash function for strings.
17340
17341 Ada.Strings.Hash_Case_Insensitive (A.4.9)
17342 This package provides a hash function for strings that is case insensitive.
17343 The string is converted to lower case before computing the hash.
17344
17345 @item Ada.Strings.Less_Case_Insensitive (A.4.10)
17346 This package provides a comparison function for\strings that works
17347 in a case insensitive manner by converting to lower case before the comparison.
17348
17349 @item Ada.Strings.Maps (A.4.2)
17350 This package provides facilities for handling character mappings and
17351 arbitrarily defined subsets of characters. For instance it is useful in
17352 defining specialized translation tables.
17353
17354 @item Ada.Strings.Maps.Constants (A.4.6)
17355 This package provides a standard set of predefined mappings and
17356 predefined character sets. For example, the standard upper to lower case
17357 conversion table is found in this package. Note that upper to lower case
17358 conversion is non-trivial if you want to take the entire set of
17359 characters, including extended characters like E with an acute accent,
17360 into account. You should use the mappings in this package (rather than
17361 adding 32 yourself) to do case mappings.
17362
17363 @item Ada.Strings.Unbounded (A.4.5)
17364 This package provides facilities for handling variable length
17365 strings. The unbounded model allows arbitrary length strings, but
17366 requires the use of dynamic allocation and finalization.
17367
17368 @item Ada.Strings.Unbounded.Equal_Case_Insensitive (A.4.10)
17369 Provides case-insensitive comparisons of unbounded strings
17370
17371 @item Ada.Strings.Unbounded.Hash (A.4.9)
17372 This package provides a generic hash function for unbounded strings
17373
17374 @item Ada.Strings.Unbounded.Hash_Case_Insensitive (A.4.9)
17375 This package provides a generic hash function for unbounded strings that
17376 converts the string to be hashed to lower case.
17377
17378 @item Ada.Strings.Unbounded.Less_Case_Insensitive (A.4.10)
17379 This package provides a comparison function for unbounded strings that works
17380 in a case insensitive manner by converting to lower case before the comparison.
17381
17382 @item Ada.Strings.UTF_Encoding (A.4.11)
17383 This package provides basic definitions for dealing with UTF-encoded strings.
17384
17385 @item Ada.Strings.UTF_Encoding.Conversions (A.4.11)
17386 This package provides conversion functions for UTF-encoded strings.
17387
17388 @item Ada.Strings.UTF_Encoding.Strings (A.4.11)
17389 @itemx Ada.Strings.UTF_Encoding.Wide_Strings (A.4.11)
17390 @itemx Ada.Strings.UTF_Encoding.Wide_Wide_Strings (A.4.11)
17391 These packages provide facilities for handling UTF encodings for
17392 Strings, Wide_Strings and Wide_Wide_Strings.
17393
17394 @item Ada.Strings.Wide_Bounded (A.4.7)
17395 @itemx Ada.Strings.Wide_Fixed (A.4.7)
17396 @itemx Ada.Strings.Wide_Maps (A.4.7)
17397 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
17398 These packages provide analogous capabilities to the corresponding
17399 packages without @samp{Wide_} in the name, but operate with the types
17400 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
17401 and @code{Character}. Versions of all the child packages are available.
17402
17403 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
17404 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
17405 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
17406 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
17407 These packages provide analogous capabilities to the corresponding
17408 packages without @samp{Wide_} in the name, but operate with the types
17409 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
17410 of @code{String} and @code{Character}.
17411
17412 @item Ada.Synchronous_Barriers (D.10.1)
17413 This package provides facilities for synchronizing tasks at a low level
17414 with barriers.
17415
17416 @item Ada.Synchronous_Task_Control (D.10)
17417 This package provides some standard facilities for controlling task
17418 communication in a synchronous manner.
17419
17420 @item Ada.Synchronous_Task_Control.EDF (D.10)
17421 Not implemented in GNAT.
17422
17423 @item Ada.Tags
17424 This package contains definitions for manipulation of the tags of tagged
17425 values.
17426
17427 @item Ada.Tags.Generic_Dispatching_Constructor (3.9)
17428 This package provides a way of constructing tagged class-wide values given
17429 only the tag value.
17430
17431 @item Ada.Task_Attributes (C.7.2)
17432 This package provides the capability of associating arbitrary
17433 task-specific data with separate tasks.
17434
17435 @item Ada.Task_Identifification (C.7.1)
17436 This package provides capabilities for task identification.
17437
17438 @item Ada.Task_Termination (C.7.3)
17439 This package provides control over task termination.
17440
17441 @item Ada.Text_IO
17442 This package provides basic text input-output capabilities for
17443 character, string and numeric data. The subpackages of this
17444 package are listed next. Note that although these are defined
17445 as subpackages in the RM, they are actually transparently
17446 implemented as child packages in GNAT, meaning that they
17447 are only loaded if needed.
17448
17449 @item Ada.Text_IO.Decimal_IO
17450 Provides input-output facilities for decimal fixed-point types
17451
17452 @item Ada.Text_IO.Enumeration_IO
17453 Provides input-output facilities for enumeration types.
17454
17455 @item Ada.Text_IO.Fixed_IO
17456 Provides input-output facilities for ordinary fixed-point types.
17457
17458 @item Ada.Text_IO.Float_IO
17459 Provides input-output facilities for float types. The following
17460 predefined instantiations of this generic package are available:
17461
17462 @table @code
17463 @item Short_Float
17464 @code{Short_Float_Text_IO}
17465 @item Float
17466 @code{Float_Text_IO}
17467 @item Long_Float
17468 @code{Long_Float_Text_IO}
17469 @end table
17470
17471 @item Ada.Text_IO.Integer_IO
17472 Provides input-output facilities for integer types. The following
17473 predefined instantiations of this generic package are available:
17474
17475 @table @code
17476 @item Short_Short_Integer
17477 @code{Ada.Short_Short_Integer_Text_IO}
17478 @item Short_Integer
17479 @code{Ada.Short_Integer_Text_IO}
17480 @item Integer
17481 @code{Ada.Integer_Text_IO}
17482 @item Long_Integer
17483 @code{Ada.Long_Integer_Text_IO}
17484 @item Long_Long_Integer
17485 @code{Ada.Long_Long_Integer_Text_IO}
17486 @end table
17487
17488 @item Ada.Text_IO.Modular_IO
17489 Provides input-output facilities for modular (unsigned) types.
17490
17491 @item Ada.Text_IO.Bounded_IO (A.10.11)
17492 Provides input-output facilities for bounded strings.
17493
17494 @item Ada.Text_IO.Complex_IO (G.1.3)
17495 This package provides basic text input-output capabilities for complex
17496 data.
17497
17498 @item Ada.Text_IO.Editing (F.3.3)
17499 This package contains routines for edited output, analogous to the use
17500 of pictures in COBOL@. The picture formats used by this package are a
17501 close copy of the facility in COBOL@.
17502
17503 @item Ada.Text_IO.Text_Streams (A.12.2)
17504 This package provides a facility that allows Text_IO files to be treated
17505 as streams, so that the stream attributes can be used for writing
17506 arbitrary data, including binary data, to Text_IO files.
17507
17508 @item Ada.Text_IO.Unbounded_IO (A.10.12)
17509 This package provides input-output facilities for unbounded strings.
17510
17511 @item Ada.Unchecked_Conversion (13.9)
17512 This generic package allows arbitrary conversion from one type to
17513 another of the same size, providing for breaking the type safety in
17514 special circumstances.
17515
17516 If the types have the same Size (more accurately the same Value_Size),
17517 then the effect is simply to transfer the bits from the source to the
17518 target type without any modification. This usage is well defined, and
17519 for simple types whose representation is typically the same across
17520 all implementations, gives a portable method of performing such
17521 conversions.
17522
17523 If the types do not have the same size, then the result is implementation
17524 defined, and thus may be non-portable. The following describes how GNAT
17525 handles such unchecked conversion cases.
17526
17527 If the types are of different sizes, and are both discrete types, then
17528 the effect is of a normal type conversion without any constraint checking.
17529 In particular if the result type has a larger size, the result will be
17530 zero or sign extended. If the result type has a smaller size, the result
17531 will be truncated by ignoring high order bits.
17532
17533 If the types are of different sizes, and are not both discrete types,
17534 then the conversion works as though pointers were created to the source
17535 and target, and the pointer value is converted. The effect is that bits
17536 are copied from successive low order storage units and bits of the source
17537 up to the length of the target type.
17538
17539 A warning is issued if the lengths differ, since the effect in this
17540 case is implementation dependent, and the above behavior may not match
17541 that of some other compiler.
17542
17543 A pointer to one type may be converted to a pointer to another type using
17544 unchecked conversion. The only case in which the effect is undefined is
17545 when one or both pointers are pointers to unconstrained array types. In
17546 this case, the bounds information may get incorrectly transferred, and in
17547 particular, GNAT uses double size pointers for such types, and it is
17548 meaningless to convert between such pointer types. GNAT will issue a
17549 warning if the alignment of the target designated type is more strict
17550 than the alignment of the source designated type (since the result may
17551 be unaligned in this case).
17552
17553 A pointer other than a pointer to an unconstrained array type may be
17554 converted to and from System.Address. Such usage is common in Ada 83
17555 programs, but note that Ada.Address_To_Access_Conversions is the
17556 preferred method of performing such conversions in Ada 95 and Ada 2005.
17557 Neither
17558 unchecked conversion nor Ada.Address_To_Access_Conversions should be
17559 used in conjunction with pointers to unconstrained objects, since
17560 the bounds information cannot be handled correctly in this case.
17561
17562 @item Ada.Unchecked_Deallocation (13.11.2)
17563 This generic package allows explicit freeing of storage previously
17564 allocated by use of an allocator.
17565
17566 @item Ada.Wide_Text_IO (A.11)
17567 This package is similar to @code{Ada.Text_IO}, except that the external
17568 file supports wide character representations, and the internal types are
17569 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17570 and @code{String}. The corresponding set of nested packages and child
17571 packages are defined.
17572
17573 @item Ada.Wide_Wide_Text_IO (A.11)
17574 This package is similar to @code{Ada.Text_IO}, except that the external
17575 file supports wide character representations, and the internal types are
17576 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
17577 and @code{String}. The corresponding set of nested packages and child
17578 packages are defined.
17579
17580 @end table
17581
17582 For packages in Interfaces and System, all the RM defined packages are
17583 available in GNAT, see the Ada 2012 RM for full details.
17584
17585 @node The Implementation of Standard I/O
17586 @chapter The Implementation of Standard I/O
17587
17588 @noindent
17589 GNAT implements all the required input-output facilities described in
17590 A.6 through A.14. These sections of the Ada Reference Manual describe the
17591 required behavior of these packages from the Ada point of view, and if
17592 you are writing a portable Ada program that does not need to know the
17593 exact manner in which Ada maps to the outside world when it comes to
17594 reading or writing external files, then you do not need to read this
17595 chapter. As long as your files are all regular files (not pipes or
17596 devices), and as long as you write and read the files only from Ada, the
17597 description in the Ada Reference Manual is sufficient.
17598
17599 However, if you want to do input-output to pipes or other devices, such
17600 as the keyboard or screen, or if the files you are dealing with are
17601 either generated by some other language, or to be read by some other
17602 language, then you need to know more about the details of how the GNAT
17603 implementation of these input-output facilities behaves.
17604
17605 In this chapter we give a detailed description of exactly how GNAT
17606 interfaces to the file system. As always, the sources of the system are
17607 available to you for answering questions at an even more detailed level,
17608 but for most purposes the information in this chapter will suffice.
17609
17610 Another reason that you may need to know more about how input-output is
17611 implemented arises when you have a program written in mixed languages
17612 where, for example, files are shared between the C and Ada sections of
17613 the same program. GNAT provides some additional facilities, in the form
17614 of additional child library packages, that facilitate this sharing, and
17615 these additional facilities are also described in this chapter.
17616
17617 @menu
17618 * Standard I/O Packages::
17619 * FORM Strings::
17620 * Direct_IO::
17621 * Sequential_IO::
17622 * Text_IO::
17623 * Wide_Text_IO::
17624 * Wide_Wide_Text_IO::
17625 * Stream_IO::
17626 * Text Translation::
17627 * Shared Files::
17628 * Filenames encoding::
17629 * File content encoding::
17630 * Open Modes::
17631 * Operations on C Streams::
17632 * Interfacing to C Streams::
17633 @end menu
17634
17635 @node Standard I/O Packages
17636 @section Standard I/O Packages
17637
17638 @noindent
17639 The Standard I/O packages described in Annex A for
17640
17641 @itemize @bullet
17642 @item
17643 Ada.Text_IO
17644 @item
17645 Ada.Text_IO.Complex_IO
17646 @item
17647 Ada.Text_IO.Text_Streams
17648 @item
17649 Ada.Wide_Text_IO
17650 @item
17651 Ada.Wide_Text_IO.Complex_IO
17652 @item
17653 Ada.Wide_Text_IO.Text_Streams
17654 @item
17655 Ada.Wide_Wide_Text_IO
17656 @item
17657 Ada.Wide_Wide_Text_IO.Complex_IO
17658 @item
17659 Ada.Wide_Wide_Text_IO.Text_Streams
17660 @item
17661 Ada.Stream_IO
17662 @item
17663 Ada.Sequential_IO
17664 @item
17665 Ada.Direct_IO
17666 @end itemize
17667
17668 @noindent
17669 are implemented using the C
17670 library streams facility; where
17671
17672 @itemize @bullet
17673 @item
17674 All files are opened using @code{fopen}.
17675 @item
17676 All input/output operations use @code{fread}/@code{fwrite}.
17677 @end itemize
17678
17679 @noindent
17680 There is no internal buffering of any kind at the Ada library level. The only
17681 buffering is that provided at the system level in the implementation of the
17682 library routines that support streams. This facilitates shared use of these
17683 streams by mixed language programs. Note though that system level buffering is
17684 explicitly enabled at elaboration of the standard I/O packages and that can
17685 have an impact on mixed language programs, in particular those using I/O before
17686 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
17687 the Ada elaboration routine before performing any I/O or when impractical,
17688 flush the common I/O streams and in particular Standard_Output before
17689 elaborating the Ada code.
17690
17691 @node FORM Strings
17692 @section FORM Strings
17693
17694 @noindent
17695 The format of a FORM string in GNAT is:
17696
17697 @smallexample
17698 "keyword=value,keyword=value,@dots{},keyword=value"
17699 @end smallexample
17700
17701 @noindent
17702 where letters may be in upper or lower case, and there are no spaces
17703 between values. The order of the entries is not important. Currently
17704 the following keywords defined.
17705
17706 @smallexample
17707 TEXT_TRANSLATION=[YES|NO|TEXT|BINARY|U8TEXT|WTEXT|U16TEXT]
17708 SHARED=[YES|NO]
17709 WCEM=[n|h|u|s|e|8|b]
17710 ENCODING=[UTF8|8BITS]
17711 @end smallexample
17712
17713 @noindent
17714 The use of these parameters is described later in this section. If an
17715 unrecognized keyword appears in a form string, it is silently ignored
17716 and not considered invalid.
17717
17718 @noindent
17719 For OpenVMS additional FORM string keywords are available for use with
17720 RMS services. The syntax is:
17721
17722 @smallexample
17723 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
17724 @end smallexample
17725
17726 @noindent
17727 The following RMS keywords and values are currently defined:
17728
17729 @smallexample
17730 Context=Force_Stream_Mode|Force_Record_Mode
17731 @end smallexample
17732
17733 @noindent
17734 VMS RMS keys are silently ignored on non-VMS systems. On OpenVMS
17735 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
17736
17737 @node Direct_IO
17738 @section Direct_IO
17739
17740 @noindent
17741 Direct_IO can only be instantiated for definite types. This is a
17742 restriction of the Ada language, which means that the records are fixed
17743 length (the length being determined by @code{@var{type}'Size}, rounded
17744 up to the next storage unit boundary if necessary).
17745
17746 The records of a Direct_IO file are simply written to the file in index
17747 sequence, with the first record starting at offset zero, and subsequent
17748 records following. There is no control information of any kind. For
17749 example, if 32-bit integers are being written, each record takes
17750 4-bytes, so the record at index @var{K} starts at offset
17751 (@var{K}@minus{}1)*4.
17752
17753 There is no limit on the size of Direct_IO files, they are expanded as
17754 necessary to accommodate whatever records are written to the file.
17755
17756 @node Sequential_IO
17757 @section Sequential_IO
17758
17759 @noindent
17760 Sequential_IO may be instantiated with either a definite (constrained)
17761 or indefinite (unconstrained) type.
17762
17763 For the definite type case, the elements written to the file are simply
17764 the memory images of the data values with no control information of any
17765 kind. The resulting file should be read using the same type, no validity
17766 checking is performed on input.
17767
17768 For the indefinite type case, the elements written consist of two
17769 parts. First is the size of the data item, written as the memory image
17770 of a @code{Interfaces.C.size_t} value, followed by the memory image of
17771 the data value. The resulting file can only be read using the same
17772 (unconstrained) type. Normal assignment checks are performed on these
17773 read operations, and if these checks fail, @code{Data_Error} is
17774 raised. In particular, in the array case, the lengths must match, and in
17775 the variant record case, if the variable for a particular read operation
17776 is constrained, the discriminants must match.
17777
17778 Note that it is not possible to use Sequential_IO to write variable
17779 length array items, and then read the data back into different length
17780 arrays. For example, the following will raise @code{Data_Error}:
17781
17782 @smallexample @c ada
17783 package IO is new Sequential_IO (String);
17784 F : IO.File_Type;
17785 S : String (1..4);
17786 @dots{}
17787 IO.Create (F)
17788 IO.Write (F, "hello!")
17789 IO.Reset (F, Mode=>In_File);
17790 IO.Read (F, S);
17791 Put_Line (S);
17792
17793 @end smallexample
17794
17795 @noindent
17796 On some Ada implementations, this will print @code{hell}, but the program is
17797 clearly incorrect, since there is only one element in the file, and that
17798 element is the string @code{hello!}.
17799
17800 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
17801 using Stream_IO, and this is the preferred mechanism. In particular, the
17802 above program fragment rewritten to use Stream_IO will work correctly.
17803
17804 @node Text_IO
17805 @section Text_IO
17806
17807 @noindent
17808 Text_IO files consist of a stream of characters containing the following
17809 special control characters:
17810
17811 @smallexample
17812 LF (line feed, 16#0A#) Line Mark
17813 FF (form feed, 16#0C#) Page Mark
17814 @end smallexample
17815
17816 @noindent
17817 A canonical Text_IO file is defined as one in which the following
17818 conditions are met:
17819
17820 @itemize @bullet
17821 @item
17822 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
17823 of the line.
17824
17825 @item
17826 The character @code{FF} is used only as a page mark, i.e.@: to mark the
17827 end of a page and consequently can appear only immediately following a
17828 @code{LF} (line mark) character.
17829
17830 @item
17831 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
17832 (line mark, page mark). In the former case, the page mark is implicitly
17833 assumed to be present.
17834 @end itemize
17835
17836 @noindent
17837 A file written using Text_IO will be in canonical form provided that no
17838 explicit @code{LF} or @code{FF} characters are written using @code{Put}
17839 or @code{Put_Line}. There will be no @code{FF} character at the end of
17840 the file unless an explicit @code{New_Page} operation was performed
17841 before closing the file.
17842
17843 A canonical Text_IO file that is a regular file (i.e., not a device or a
17844 pipe) can be read using any of the routines in Text_IO@. The
17845 semantics in this case will be exactly as defined in the Ada Reference
17846 Manual, and all the routines in Text_IO are fully implemented.
17847
17848 A text file that does not meet the requirements for a canonical Text_IO
17849 file has one of the following:
17850
17851 @itemize @bullet
17852 @item
17853 The file contains @code{FF} characters not immediately following a
17854 @code{LF} character.
17855
17856 @item
17857 The file contains @code{LF} or @code{FF} characters written by
17858 @code{Put} or @code{Put_Line}, which are not logically considered to be
17859 line marks or page marks.
17860
17861 @item
17862 The file ends in a character other than @code{LF} or @code{FF},
17863 i.e.@: there is no explicit line mark or page mark at the end of the file.
17864 @end itemize
17865
17866 @noindent
17867 Text_IO can be used to read such non-standard text files but subprograms
17868 to do with line or page numbers do not have defined meanings. In
17869 particular, a @code{FF} character that does not follow a @code{LF}
17870 character may or may not be treated as a page mark from the point of
17871 view of page and line numbering. Every @code{LF} character is considered
17872 to end a line, and there is an implied @code{LF} character at the end of
17873 the file.
17874
17875 @menu
17876 * Text_IO Stream Pointer Positioning::
17877 * Text_IO Reading and Writing Non-Regular Files::
17878 * Get_Immediate::
17879 * Treating Text_IO Files as Streams::
17880 * Text_IO Extensions::
17881 * Text_IO Facilities for Unbounded Strings::
17882 @end menu
17883
17884 @node Text_IO Stream Pointer Positioning
17885 @subsection Stream Pointer Positioning
17886
17887 @noindent
17888 @code{Ada.Text_IO} has a definition of current position for a file that
17889 is being read. No internal buffering occurs in Text_IO, and usually the
17890 physical position in the stream used to implement the file corresponds
17891 to this logical position defined by Text_IO@. There are two exceptions:
17892
17893 @itemize @bullet
17894 @item
17895 After a call to @code{End_Of_Page} that returns @code{True}, the stream
17896 is positioned past the @code{LF} (line mark) that precedes the page
17897 mark. Text_IO maintains an internal flag so that subsequent read
17898 operations properly handle the logical position which is unchanged by
17899 the @code{End_Of_Page} call.
17900
17901 @item
17902 After a call to @code{End_Of_File} that returns @code{True}, if the
17903 Text_IO file was positioned before the line mark at the end of file
17904 before the call, then the logical position is unchanged, but the stream
17905 is physically positioned right at the end of file (past the line mark,
17906 and past a possible page mark following the line mark. Again Text_IO
17907 maintains internal flags so that subsequent read operations properly
17908 handle the logical position.
17909 @end itemize
17910
17911 @noindent
17912 These discrepancies have no effect on the observable behavior of
17913 Text_IO, but if a single Ada stream is shared between a C program and
17914 Ada program, or shared (using @samp{shared=yes} in the form string)
17915 between two Ada files, then the difference may be observable in some
17916 situations.
17917
17918 @node Text_IO Reading and Writing Non-Regular Files
17919 @subsection Reading and Writing Non-Regular Files
17920
17921 @noindent
17922 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
17923 can be used for reading and writing. Writing is not affected and the
17924 sequence of characters output is identical to the normal file case, but
17925 for reading, the behavior of Text_IO is modified to avoid undesirable
17926 look-ahead as follows:
17927
17928 An input file that is not a regular file is considered to have no page
17929 marks. Any @code{Ascii.FF} characters (the character normally used for a
17930 page mark) appearing in the file are considered to be data
17931 characters. In particular:
17932
17933 @itemize @bullet
17934 @item
17935 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
17936 following a line mark. If a page mark appears, it will be treated as a
17937 data character.
17938
17939 @item
17940 This avoids the need to wait for an extra character to be typed or
17941 entered from the pipe to complete one of these operations.
17942
17943 @item
17944 @code{End_Of_Page} always returns @code{False}
17945
17946 @item
17947 @code{End_Of_File} will return @code{False} if there is a page mark at
17948 the end of the file.
17949 @end itemize
17950
17951 @noindent
17952 Output to non-regular files is the same as for regular files. Page marks
17953 may be written to non-regular files using @code{New_Page}, but as noted
17954 above they will not be treated as page marks on input if the output is
17955 piped to another Ada program.
17956
17957 Another important discrepancy when reading non-regular files is that the end
17958 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
17959 pressing the @key{EOT} key,
17960 then end of file
17961 is signaled once (i.e.@: the test @code{End_Of_File}
17962 will yield @code{True}, or a read will
17963 raise @code{End_Error}), but then reading can resume
17964 to read data past that end of
17965 file indication, until another end of file indication is entered.
17966
17967 @node Get_Immediate
17968 @subsection Get_Immediate
17969 @cindex Get_Immediate
17970
17971 @noindent
17972 Get_Immediate returns the next character (including control characters)
17973 from the input file. In particular, Get_Immediate will return LF or FF
17974 characters used as line marks or page marks. Such operations leave the
17975 file positioned past the control character, and it is thus not treated
17976 as having its normal function. This means that page, line and column
17977 counts after this kind of Get_Immediate call are set as though the mark
17978 did not occur. In the case where a Get_Immediate leaves the file
17979 positioned between the line mark and page mark (which is not normally
17980 possible), it is undefined whether the FF character will be treated as a
17981 page mark.
17982
17983 @node Treating Text_IO Files as Streams
17984 @subsection Treating Text_IO Files as Streams
17985 @cindex Stream files
17986
17987 @noindent
17988 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
17989 as a stream. Data written to a Text_IO file in this stream mode is
17990 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
17991 16#0C# (@code{FF}), the resulting file may have non-standard
17992 format. Similarly if read operations are used to read from a Text_IO
17993 file treated as a stream, then @code{LF} and @code{FF} characters may be
17994 skipped and the effect is similar to that described above for
17995 @code{Get_Immediate}.
17996
17997 @node Text_IO Extensions
17998 @subsection Text_IO Extensions
17999 @cindex Text_IO extensions
18000
18001 @noindent
18002 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
18003 to the standard @code{Text_IO} package:
18004
18005 @itemize @bullet
18006 @item function File_Exists (Name : String) return Boolean;
18007 Determines if a file of the given name exists.
18008
18009 @item function Get_Line return String;
18010 Reads a string from the standard input file. The value returned is exactly
18011 the length of the line that was read.
18012
18013 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
18014 Similar, except that the parameter File specifies the file from which
18015 the string is to be read.
18016
18017 @end itemize
18018
18019 @node Text_IO Facilities for Unbounded Strings
18020 @subsection Text_IO Facilities for Unbounded Strings
18021 @cindex Text_IO for unbounded strings
18022 @cindex Unbounded_String, Text_IO operations
18023
18024 @noindent
18025 The package @code{Ada.Strings.Unbounded.Text_IO}
18026 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
18027 subprograms useful for Text_IO operations on unbounded strings:
18028
18029 @itemize @bullet
18030
18031 @item function Get_Line (File : File_Type) return Unbounded_String;
18032 Reads a line from the specified file
18033 and returns the result as an unbounded string.
18034
18035 @item procedure Put (File : File_Type; U : Unbounded_String);
18036 Writes the value of the given unbounded string to the specified file
18037 Similar to the effect of
18038 @code{Put (To_String (U))} except that an extra copy is avoided.
18039
18040 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
18041 Writes the value of the given unbounded string to the specified file,
18042 followed by a @code{New_Line}.
18043 Similar to the effect of @code{Put_Line (To_String (U))} except
18044 that an extra copy is avoided.
18045 @end itemize
18046
18047 @noindent
18048 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
18049 and is optional. If the parameter is omitted, then the standard input or
18050 output file is referenced as appropriate.
18051
18052 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
18053 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
18054 @code{Wide_Text_IO} functionality for unbounded wide strings.
18055
18056 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
18057 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
18058 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
18059
18060 @node Wide_Text_IO
18061 @section Wide_Text_IO
18062
18063 @noindent
18064 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
18065 both input and output files may contain special sequences that represent
18066 wide character values. The encoding scheme for a given file may be
18067 specified using a FORM parameter:
18068
18069 @smallexample
18070 WCEM=@var{x}
18071 @end smallexample
18072
18073 @noindent
18074 as part of the FORM string (WCEM = wide character encoding method),
18075 where @var{x} is one of the following characters
18076
18077 @table @samp
18078 @item h
18079 Hex ESC encoding
18080 @item u
18081 Upper half encoding
18082 @item s
18083 Shift-JIS encoding
18084 @item e
18085 EUC Encoding
18086 @item 8
18087 UTF-8 encoding
18088 @item b
18089 Brackets encoding
18090 @end table
18091
18092 @noindent
18093 The encoding methods match those that
18094 can be used in a source
18095 program, but there is no requirement that the encoding method used for
18096 the source program be the same as the encoding method used for files,
18097 and different files may use different encoding methods.
18098
18099 The default encoding method for the standard files, and for opened files
18100 for which no WCEM parameter is given in the FORM string matches the
18101 wide character encoding specified for the main program (the default
18102 being brackets encoding if no coding method was specified with -gnatW).
18103
18104 @table @asis
18105 @item Hex Coding
18106 In this encoding, a wide character is represented by a five character
18107 sequence:
18108
18109 @smallexample
18110 ESC a b c d
18111 @end smallexample
18112
18113 @noindent
18114 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
18115 characters (using upper case letters) of the wide character code. For
18116 example, ESC A345 is used to represent the wide character with code
18117 16#A345#. This scheme is compatible with use of the full
18118 @code{Wide_Character} set.
18119
18120 @item Upper Half Coding
18121 The wide character with encoding 16#abcd#, where the upper bit is on
18122 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
18123 16#cd#. The second byte may never be a format control character, but is
18124 not required to be in the upper half. This method can be also used for
18125 shift-JIS or EUC where the internal coding matches the external coding.
18126
18127 @item Shift JIS Coding
18128 A wide character is represented by a two character sequence 16#ab# and
18129 16#cd#, with the restrictions described for upper half encoding as
18130 described above. The internal character code is the corresponding JIS
18131 character according to the standard algorithm for Shift-JIS
18132 conversion. Only characters defined in the JIS code set table can be
18133 used with this encoding method.
18134
18135 @item EUC Coding
18136 A wide character is represented by a two character sequence 16#ab# and
18137 16#cd#, with both characters being in the upper half. The internal
18138 character code is the corresponding JIS character according to the EUC
18139 encoding algorithm. Only characters defined in the JIS code set table
18140 can be used with this encoding method.
18141
18142 @item UTF-8 Coding
18143 A wide character is represented using
18144 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
18145 10646-1/Am.2. Depending on the character value, the representation
18146 is a one, two, or three byte sequence:
18147
18148 @smallexample
18149 16#0000#-16#007f#: 2#0xxxxxxx#
18150 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
18151 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
18152 @end smallexample
18153
18154 @noindent
18155 where the @var{xxx} bits correspond to the left-padded bits of the
18156 16-bit character value. Note that all lower half ASCII characters
18157 are represented as ASCII bytes and all upper half characters and
18158 other wide characters are represented as sequences of upper-half
18159 (The full UTF-8 scheme allows for encoding 31-bit characters as
18160 6-byte sequences, but in this implementation, all UTF-8 sequences
18161 of four or more bytes length will raise a Constraint_Error, as
18162 will all invalid UTF-8 sequences.)
18163
18164 @item Brackets Coding
18165 In this encoding, a wide character is represented by the following eight
18166 character sequence:
18167
18168 @smallexample
18169 [ " a b c d " ]
18170 @end smallexample
18171
18172 @noindent
18173 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
18174 characters (using uppercase letters) of the wide character code. For
18175 example, @code{["A345"]} is used to represent the wide character with code
18176 @code{16#A345#}.
18177 This scheme is compatible with use of the full Wide_Character set.
18178 On input, brackets coding can also be used for upper half characters,
18179 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
18180 is only used for wide characters with a code greater than @code{16#FF#}.
18181
18182 Note that brackets coding is not normally used in the context of
18183 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
18184 a portable way of encoding source files. In the context of Wide_Text_IO
18185 or Wide_Wide_Text_IO, it can only be used if the file does not contain
18186 any instance of the left bracket character other than to encode wide
18187 character values using the brackets encoding method. In practice it is
18188 expected that some standard wide character encoding method such
18189 as UTF-8 will be used for text input output.
18190
18191 If brackets notation is used, then any occurrence of a left bracket
18192 in the input file which is not the start of a valid wide character
18193 sequence will cause Constraint_Error to be raised. It is possible to
18194 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
18195 input will interpret this as a left bracket.
18196
18197 However, when a left bracket is output, it will be output as a left bracket
18198 and not as ["5B"]. We make this decision because for normal use of
18199 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
18200 brackets. For example, if we write:
18201
18202 @smallexample
18203 Put_Line ("Start of output [first run]");
18204 @end smallexample
18205
18206 @noindent
18207 we really do not want to have the left bracket in this message clobbered so
18208 that the output reads:
18209
18210 @smallexample
18211 Start of output ["5B"]first run]
18212 @end smallexample
18213
18214 @noindent
18215 In practice brackets encoding is reasonably useful for normal Put_Line use
18216 since we won't get confused between left brackets and wide character
18217 sequences in the output. But for input, or when files are written out
18218 and read back in, it really makes better sense to use one of the standard
18219 encoding methods such as UTF-8.
18220
18221 @end table
18222
18223 @noindent
18224 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
18225 not all wide character
18226 values can be represented. An attempt to output a character that cannot
18227 be represented using the encoding scheme for the file causes
18228 Constraint_Error to be raised. An invalid wide character sequence on
18229 input also causes Constraint_Error to be raised.
18230
18231 @menu
18232 * Wide_Text_IO Stream Pointer Positioning::
18233 * Wide_Text_IO Reading and Writing Non-Regular Files::
18234 @end menu
18235
18236 @node Wide_Text_IO Stream Pointer Positioning
18237 @subsection Stream Pointer Positioning
18238
18239 @noindent
18240 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
18241 of stream pointer positioning (@pxref{Text_IO}). There is one additional
18242 case:
18243
18244 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
18245 normal lower ASCII set (i.e.@: a character in the range:
18246
18247 @smallexample @c ada
18248 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
18249 @end smallexample
18250
18251 @noindent
18252 then although the logical position of the file pointer is unchanged by
18253 the @code{Look_Ahead} call, the stream is physically positioned past the
18254 wide character sequence. Again this is to avoid the need for buffering
18255 or backup, and all @code{Wide_Text_IO} routines check the internal
18256 indication that this situation has occurred so that this is not visible
18257 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
18258 can be observed if the wide text file shares a stream with another file.
18259
18260 @node Wide_Text_IO Reading and Writing Non-Regular Files
18261 @subsection Reading and Writing Non-Regular Files
18262
18263 @noindent
18264 As in the case of Text_IO, when a non-regular file is read, it is
18265 assumed that the file contains no page marks (any form characters are
18266 treated as data characters), and @code{End_Of_Page} always returns
18267 @code{False}. Similarly, the end of file indication is not sticky, so
18268 it is possible to read beyond an end of file.
18269
18270 @node Wide_Wide_Text_IO
18271 @section Wide_Wide_Text_IO
18272
18273 @noindent
18274 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
18275 both input and output files may contain special sequences that represent
18276 wide wide character values. The encoding scheme for a given file may be
18277 specified using a FORM parameter:
18278
18279 @smallexample
18280 WCEM=@var{x}
18281 @end smallexample
18282
18283 @noindent
18284 as part of the FORM string (WCEM = wide character encoding method),
18285 where @var{x} is one of the following characters
18286
18287 @table @samp
18288 @item h
18289 Hex ESC encoding
18290 @item u
18291 Upper half encoding
18292 @item s
18293 Shift-JIS encoding
18294 @item e
18295 EUC Encoding
18296 @item 8
18297 UTF-8 encoding
18298 @item b
18299 Brackets encoding
18300 @end table
18301
18302 @noindent
18303 The encoding methods match those that
18304 can be used in a source
18305 program, but there is no requirement that the encoding method used for
18306 the source program be the same as the encoding method used for files,
18307 and different files may use different encoding methods.
18308
18309 The default encoding method for the standard files, and for opened files
18310 for which no WCEM parameter is given in the FORM string matches the
18311 wide character encoding specified for the main program (the default
18312 being brackets encoding if no coding method was specified with -gnatW).
18313
18314 @table @asis
18315
18316 @item UTF-8 Coding
18317 A wide character is represented using
18318 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
18319 10646-1/Am.2. Depending on the character value, the representation
18320 is a one, two, three, or four byte sequence:
18321
18322 @smallexample
18323 16#000000#-16#00007f#: 2#0xxxxxxx#
18324 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
18325 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
18326 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
18327 @end smallexample
18328
18329 @noindent
18330 where the @var{xxx} bits correspond to the left-padded bits of the
18331 21-bit character value. Note that all lower half ASCII characters
18332 are represented as ASCII bytes and all upper half characters and
18333 other wide characters are represented as sequences of upper-half
18334 characters.
18335
18336 @item Brackets Coding
18337 In this encoding, a wide wide character is represented by the following eight
18338 character sequence if is in wide character range
18339
18340 @smallexample
18341 [ " a b c d " ]
18342 @end smallexample
18343
18344 and by the following ten character sequence if not
18345
18346 @smallexample
18347 [ " a b c d e f " ]
18348 @end smallexample
18349
18350 @noindent
18351 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
18352 are the four or six hexadecimal
18353 characters (using uppercase letters) of the wide wide character code. For
18354 example, @code{["01A345"]} is used to represent the wide wide character
18355 with code @code{16#01A345#}.
18356
18357 This scheme is compatible with use of the full Wide_Wide_Character set.
18358 On input, brackets coding can also be used for upper half characters,
18359 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
18360 is only used for wide characters with a code greater than @code{16#FF#}.
18361
18362 @end table
18363
18364 @noindent
18365 If is also possible to use the other Wide_Character encoding methods,
18366 such as Shift-JIS, but the other schemes cannot support the full range
18367 of wide wide characters.
18368 An attempt to output a character that cannot
18369 be represented using the encoding scheme for the file causes
18370 Constraint_Error to be raised. An invalid wide character sequence on
18371 input also causes Constraint_Error to be raised.
18372
18373 @menu
18374 * Wide_Wide_Text_IO Stream Pointer Positioning::
18375 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
18376 @end menu
18377
18378 @node Wide_Wide_Text_IO Stream Pointer Positioning
18379 @subsection Stream Pointer Positioning
18380
18381 @noindent
18382 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
18383 of stream pointer positioning (@pxref{Text_IO}). There is one additional
18384 case:
18385
18386 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
18387 normal lower ASCII set (i.e.@: a character in the range:
18388
18389 @smallexample @c ada
18390 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
18391 @end smallexample
18392
18393 @noindent
18394 then although the logical position of the file pointer is unchanged by
18395 the @code{Look_Ahead} call, the stream is physically positioned past the
18396 wide character sequence. Again this is to avoid the need for buffering
18397 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
18398 indication that this situation has occurred so that this is not visible
18399 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
18400 can be observed if the wide text file shares a stream with another file.
18401
18402 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
18403 @subsection Reading and Writing Non-Regular Files
18404
18405 @noindent
18406 As in the case of Text_IO, when a non-regular file is read, it is
18407 assumed that the file contains no page marks (any form characters are
18408 treated as data characters), and @code{End_Of_Page} always returns
18409 @code{False}. Similarly, the end of file indication is not sticky, so
18410 it is possible to read beyond an end of file.
18411
18412 @node Stream_IO
18413 @section Stream_IO
18414
18415 @noindent
18416 A stream file is a sequence of bytes, where individual elements are
18417 written to the file as described in the Ada Reference Manual. The type
18418 @code{Stream_Element} is simply a byte. There are two ways to read or
18419 write a stream file.
18420
18421 @itemize @bullet
18422 @item
18423 The operations @code{Read} and @code{Write} directly read or write a
18424 sequence of stream elements with no control information.
18425
18426 @item
18427 The stream attributes applied to a stream file transfer data in the
18428 manner described for stream attributes.
18429 @end itemize
18430
18431 @node Text Translation
18432 @section Text Translation
18433
18434 @noindent
18435 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
18436 passed to Text_IO.Create and Text_IO.Open. @samp{Text_Translation=@var{xxx}}
18437 has no effect on Unix systems. Possible values are:
18438
18439 @itemize @bullet
18440
18441 @item
18442 @samp{@var{Yes} or @var{Text}} is the default, which means to
18443 translate LF to/from CR/LF on Windows systems.
18444
18445 @samp{@var{No}} disables this translation; i.e. it
18446 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
18447 may be used to create Unix-style files on
18448 Windows.
18449
18450 @item
18451 @samp{@var{wtext}} translation enabled in Unicode mode.
18452 (corresponds to _O_WTEXT).
18453
18454 @item
18455 @samp{@var{u8text}} translation enabled in Unicode UTF-8 mode.
18456 (corresponds to O_U8TEXT).
18457
18458 @item
18459 @samp{@var{u16text}} translation enabled in Unicode UTF-16
18460 mode. (corresponds to_O_U16TEXT).
18461
18462 @end itemize
18463
18464
18465
18466 @node Shared Files
18467 @section Shared Files
18468
18469 @noindent
18470 Section A.14 of the Ada Reference Manual allows implementations to
18471 provide a wide variety of behavior if an attempt is made to access the
18472 same external file with two or more internal files.
18473
18474 To provide a full range of functionality, while at the same time
18475 minimizing the problems of portability caused by this implementation
18476 dependence, GNAT handles file sharing as follows:
18477
18478 @itemize @bullet
18479 @item
18480 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
18481 to open two or more files with the same full name is considered an error
18482 and is not supported. The exception @code{Use_Error} will be
18483 raised. Note that a file that is not explicitly closed by the program
18484 remains open until the program terminates.
18485
18486 @item
18487 If the form parameter @samp{shared=no} appears in the form string, the
18488 file can be opened or created with its own separate stream identifier,
18489 regardless of whether other files sharing the same external file are
18490 opened. The exact effect depends on how the C stream routines handle
18491 multiple accesses to the same external files using separate streams.
18492
18493 @item
18494 If the form parameter @samp{shared=yes} appears in the form string for
18495 each of two or more files opened using the same full name, the same
18496 stream is shared between these files, and the semantics are as described
18497 in Ada Reference Manual, Section A.14.
18498 @end itemize
18499
18500 @noindent
18501 When a program that opens multiple files with the same name is ported
18502 from another Ada compiler to GNAT, the effect will be that
18503 @code{Use_Error} is raised.
18504
18505 The documentation of the original compiler and the documentation of the
18506 program should then be examined to determine if file sharing was
18507 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
18508 and @code{Create} calls as required.
18509
18510 When a program is ported from GNAT to some other Ada compiler, no
18511 special attention is required unless the @samp{shared=@var{xxx}} form
18512 parameter is used in the program. In this case, you must examine the
18513 documentation of the new compiler to see if it supports the required
18514 file sharing semantics, and form strings modified appropriately. Of
18515 course it may be the case that the program cannot be ported if the
18516 target compiler does not support the required functionality. The best
18517 approach in writing portable code is to avoid file sharing (and hence
18518 the use of the @samp{shared=@var{xxx}} parameter in the form string)
18519 completely.
18520
18521 One common use of file sharing in Ada 83 is the use of instantiations of
18522 Sequential_IO on the same file with different types, to achieve
18523 heterogeneous input-output. Although this approach will work in GNAT if
18524 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
18525 for this purpose (using the stream attributes)
18526
18527 @node Filenames encoding
18528 @section Filenames encoding
18529
18530 @noindent
18531 An encoding form parameter can be used to specify the filename
18532 encoding @samp{encoding=@var{xxx}}.
18533
18534 @itemize @bullet
18535 @item
18536 If the form parameter @samp{encoding=utf8} appears in the form string, the
18537 filename must be encoded in UTF-8.
18538
18539 @item
18540 If the form parameter @samp{encoding=8bits} appears in the form
18541 string, the filename must be a standard 8bits string.
18542 @end itemize
18543
18544 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
18545 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
18546 variable. And if not set @samp{utf8} is assumed.
18547
18548 @table @samp
18549 @item CP_ACP
18550 The current system Windows ANSI code page.
18551 @item CP_UTF8
18552 UTF-8 encoding
18553 @end table
18554
18555 This encoding form parameter is only supported on the Windows
18556 platform. On the other Operating Systems the run-time is supporting
18557 UTF-8 natively.
18558
18559 @node File content encoding
18560 @section File content encoding
18561
18562 @noindent
18563 For text files it is possible to specify the encoding to use. This is
18564 controlled by the by the @samp{GNAT_CCS_ENCODING} environment
18565 variable. And if not set @samp{TEXT} is assumed.
18566
18567 The possible values are those supported on Windows:
18568
18569 @table @samp
18570 @item TEXT
18571 Translated text mode
18572 @item WTEXT
18573 Translated unicode encoding
18574 @item U16TEXT
18575 Unicode 16-bit encoding
18576 @item U8TEXT
18577 Unicode 8-bit encoding
18578 @end table
18579
18580 This encoding is only supported on the Windows platform.
18581
18582 @node Open Modes
18583 @section Open Modes
18584
18585 @noindent
18586 @code{Open} and @code{Create} calls result in a call to @code{fopen}
18587 using the mode shown in the following table:
18588
18589 @sp 2
18590 @center @code{Open} and @code{Create} Call Modes
18591 @smallexample
18592 @b{OPEN } @b{CREATE}
18593 Append_File "r+" "w+"
18594 In_File "r" "w+"
18595 Out_File (Direct_IO) "r+" "w"
18596 Out_File (all other cases) "w" "w"
18597 Inout_File "r+" "w+"
18598 @end smallexample
18599
18600 @noindent
18601 If text file translation is required, then either @samp{b} or @samp{t}
18602 is added to the mode, depending on the setting of Text. Text file
18603 translation refers to the mapping of CR/LF sequences in an external file
18604 to LF characters internally. This mapping only occurs in DOS and
18605 DOS-like systems, and is not relevant to other systems.
18606
18607 A special case occurs with Stream_IO@. As shown in the above table, the
18608 file is initially opened in @samp{r} or @samp{w} mode for the
18609 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
18610 subsequently requires switching from reading to writing or vice-versa,
18611 then the file is reopened in @samp{r+} mode to permit the required operation.
18612
18613 @node Operations on C Streams
18614 @section Operations on C Streams
18615 The package @code{Interfaces.C_Streams} provides an Ada program with direct
18616 access to the C library functions for operations on C streams:
18617
18618 @smallexample @c adanocomment
18619 package Interfaces.C_Streams is
18620 -- Note: the reason we do not use the types that are in
18621 -- Interfaces.C is that we want to avoid dragging in the
18622 -- code in this unit if possible.
18623 subtype chars is System.Address;
18624 -- Pointer to null-terminated array of characters
18625 subtype FILEs is System.Address;
18626 -- Corresponds to the C type FILE*
18627 subtype voids is System.Address;
18628 -- Corresponds to the C type void*
18629 subtype int is Integer;
18630 subtype long is Long_Integer;
18631 -- Note: the above types are subtypes deliberately, and it
18632 -- is part of this spec that the above correspondences are
18633 -- guaranteed. This means that it is legitimate to, for
18634 -- example, use Integer instead of int. We provide these
18635 -- synonyms for clarity, but in some cases it may be
18636 -- convenient to use the underlying types (for example to
18637 -- avoid an unnecessary dependency of a spec on the spec
18638 -- of this unit).
18639 type size_t is mod 2 ** Standard'Address_Size;
18640 NULL_Stream : constant FILEs;
18641 -- Value returned (NULL in C) to indicate an
18642 -- fdopen/fopen/tmpfile error
18643 ----------------------------------
18644 -- Constants Defined in stdio.h --
18645 ----------------------------------
18646 EOF : constant int;
18647 -- Used by a number of routines to indicate error or
18648 -- end of file
18649 IOFBF : constant int;
18650 IOLBF : constant int;
18651 IONBF : constant int;
18652 -- Used to indicate buffering mode for setvbuf call
18653 SEEK_CUR : constant int;
18654 SEEK_END : constant int;
18655 SEEK_SET : constant int;
18656 -- Used to indicate origin for fseek call
18657 function stdin return FILEs;
18658 function stdout return FILEs;
18659 function stderr return FILEs;
18660 -- Streams associated with standard files
18661 --------------------------
18662 -- Standard C functions --
18663 --------------------------
18664 -- The functions selected below are ones that are
18665 -- available in UNIX (but not necessarily in ANSI C).
18666 -- These are very thin interfaces
18667 -- which copy exactly the C headers. For more
18668 -- documentation on these functions, see the Microsoft C
18669 -- "Run-Time Library Reference" (Microsoft Press, 1990,
18670 -- ISBN 1-55615-225-6), which includes useful information
18671 -- on system compatibility.
18672 procedure clearerr (stream : FILEs);
18673 function fclose (stream : FILEs) return int;
18674 function fdopen (handle : int; mode : chars) return FILEs;
18675 function feof (stream : FILEs) return int;
18676 function ferror (stream : FILEs) return int;
18677 function fflush (stream : FILEs) return int;
18678 function fgetc (stream : FILEs) return int;
18679 function fgets (strng : chars; n : int; stream : FILEs)
18680 return chars;
18681 function fileno (stream : FILEs) return int;
18682 function fopen (filename : chars; Mode : chars)
18683 return FILEs;
18684 -- Note: to maintain target independence, use
18685 -- text_translation_required, a boolean variable defined in
18686 -- a-sysdep.c to deal with the target dependent text
18687 -- translation requirement. If this variable is set,
18688 -- then b/t should be appended to the standard mode
18689 -- argument to set the text translation mode off or on
18690 -- as required.
18691 function fputc (C : int; stream : FILEs) return int;
18692 function fputs (Strng : chars; Stream : FILEs) return int;
18693 function fread
18694 (buffer : voids;
18695 size : size_t;
18696 count : size_t;
18697 stream : FILEs)
18698 return size_t;
18699 function freopen
18700 (filename : chars;
18701 mode : chars;
18702 stream : FILEs)
18703 return FILEs;
18704 function fseek
18705 (stream : FILEs;
18706 offset : long;
18707 origin : int)
18708 return int;
18709 function ftell (stream : FILEs) return long;
18710 function fwrite
18711 (buffer : voids;
18712 size : size_t;
18713 count : size_t;
18714 stream : FILEs)
18715 return size_t;
18716 function isatty (handle : int) return int;
18717 procedure mktemp (template : chars);
18718 -- The return value (which is just a pointer to template)
18719 -- is discarded
18720 procedure rewind (stream : FILEs);
18721 function rmtmp return int;
18722 function setvbuf
18723 (stream : FILEs;
18724 buffer : chars;
18725 mode : int;
18726 size : size_t)
18727 return int;
18728
18729 function tmpfile return FILEs;
18730 function ungetc (c : int; stream : FILEs) return int;
18731 function unlink (filename : chars) return int;
18732 ---------------------
18733 -- Extra functions --
18734 ---------------------
18735 -- These functions supply slightly thicker bindings than
18736 -- those above. They are derived from functions in the
18737 -- C Run-Time Library, but may do a bit more work than
18738 -- just directly calling one of the Library functions.
18739 function is_regular_file (handle : int) return int;
18740 -- Tests if given handle is for a regular file (result 1)
18741 -- or for a non-regular file (pipe or device, result 0).
18742 ---------------------------------
18743 -- Control of Text/Binary Mode --
18744 ---------------------------------
18745 -- If text_translation_required is true, then the following
18746 -- functions may be used to dynamically switch a file from
18747 -- binary to text mode or vice versa. These functions have
18748 -- no effect if text_translation_required is false (i.e.@: in
18749 -- normal UNIX mode). Use fileno to get a stream handle.
18750 procedure set_binary_mode (handle : int);
18751 procedure set_text_mode (handle : int);
18752 ----------------------------
18753 -- Full Path Name support --
18754 ----------------------------
18755 procedure full_name (nam : chars; buffer : chars);
18756 -- Given a NUL terminated string representing a file
18757 -- name, returns in buffer a NUL terminated string
18758 -- representing the full path name for the file name.
18759 -- On systems where it is relevant the drive is also
18760 -- part of the full path name. It is the responsibility
18761 -- of the caller to pass an actual parameter for buffer
18762 -- that is big enough for any full path name. Use
18763 -- max_path_len given below as the size of buffer.
18764 max_path_len : integer;
18765 -- Maximum length of an allowable full path name on the
18766 -- system, including a terminating NUL character.
18767 end Interfaces.C_Streams;
18768 @end smallexample
18769
18770 @node Interfacing to C Streams
18771 @section Interfacing to C Streams
18772
18773 @noindent
18774 The packages in this section permit interfacing Ada files to C Stream
18775 operations.
18776
18777 @smallexample @c ada
18778 with Interfaces.C_Streams;
18779 package Ada.Sequential_IO.C_Streams is
18780 function C_Stream (F : File_Type)
18781 return Interfaces.C_Streams.FILEs;
18782 procedure Open
18783 (File : in out File_Type;
18784 Mode : in File_Mode;
18785 C_Stream : in Interfaces.C_Streams.FILEs;
18786 Form : in String := "");
18787 end Ada.Sequential_IO.C_Streams;
18788
18789 with Interfaces.C_Streams;
18790 package Ada.Direct_IO.C_Streams is
18791 function C_Stream (F : File_Type)
18792 return Interfaces.C_Streams.FILEs;
18793 procedure Open
18794 (File : in out File_Type;
18795 Mode : in File_Mode;
18796 C_Stream : in Interfaces.C_Streams.FILEs;
18797 Form : in String := "");
18798 end Ada.Direct_IO.C_Streams;
18799
18800 with Interfaces.C_Streams;
18801 package Ada.Text_IO.C_Streams is
18802 function C_Stream (F : File_Type)
18803 return Interfaces.C_Streams.FILEs;
18804 procedure Open
18805 (File : in out File_Type;
18806 Mode : in File_Mode;
18807 C_Stream : in Interfaces.C_Streams.FILEs;
18808 Form : in String := "");
18809 end Ada.Text_IO.C_Streams;
18810
18811 with Interfaces.C_Streams;
18812 package Ada.Wide_Text_IO.C_Streams is
18813 function C_Stream (F : File_Type)
18814 return Interfaces.C_Streams.FILEs;
18815 procedure Open
18816 (File : in out File_Type;
18817 Mode : in File_Mode;
18818 C_Stream : in Interfaces.C_Streams.FILEs;
18819 Form : in String := "");
18820 end Ada.Wide_Text_IO.C_Streams;
18821
18822 with Interfaces.C_Streams;
18823 package Ada.Wide_Wide_Text_IO.C_Streams is
18824 function C_Stream (F : File_Type)
18825 return Interfaces.C_Streams.FILEs;
18826 procedure Open
18827 (File : in out File_Type;
18828 Mode : in File_Mode;
18829 C_Stream : in Interfaces.C_Streams.FILEs;
18830 Form : in String := "");
18831 end Ada.Wide_Wide_Text_IO.C_Streams;
18832
18833 with Interfaces.C_Streams;
18834 package Ada.Stream_IO.C_Streams is
18835 function C_Stream (F : File_Type)
18836 return Interfaces.C_Streams.FILEs;
18837 procedure Open
18838 (File : in out File_Type;
18839 Mode : in File_Mode;
18840 C_Stream : in Interfaces.C_Streams.FILEs;
18841 Form : in String := "");
18842 end Ada.Stream_IO.C_Streams;
18843 @end smallexample
18844
18845 @noindent
18846 In each of these six packages, the @code{C_Stream} function obtains the
18847 @code{FILE} pointer from a currently opened Ada file. It is then
18848 possible to use the @code{Interfaces.C_Streams} package to operate on
18849 this stream, or the stream can be passed to a C program which can
18850 operate on it directly. Of course the program is responsible for
18851 ensuring that only appropriate sequences of operations are executed.
18852
18853 One particular use of relevance to an Ada program is that the
18854 @code{setvbuf} function can be used to control the buffering of the
18855 stream used by an Ada file. In the absence of such a call the standard
18856 default buffering is used.
18857
18858 The @code{Open} procedures in these packages open a file giving an
18859 existing C Stream instead of a file name. Typically this stream is
18860 imported from a C program, allowing an Ada file to operate on an
18861 existing C file.
18862
18863 @node The GNAT Library
18864 @chapter The GNAT Library
18865
18866 @noindent
18867 The GNAT library contains a number of general and special purpose packages.
18868 It represents functionality that the GNAT developers have found useful, and
18869 which is made available to GNAT users. The packages described here are fully
18870 supported, and upwards compatibility will be maintained in future releases,
18871 so you can use these facilities with the confidence that the same functionality
18872 will be available in future releases.
18873
18874 The chapter here simply gives a brief summary of the facilities available.
18875 The full documentation is found in the spec file for the package. The full
18876 sources of these library packages, including both spec and body, are provided
18877 with all GNAT releases. For example, to find out the full specifications of
18878 the SPITBOL pattern matching capability, including a full tutorial and
18879 extensive examples, look in the @file{g-spipat.ads} file in the library.
18880
18881 For each entry here, the package name (as it would appear in a @code{with}
18882 clause) is given, followed by the name of the corresponding spec file in
18883 parentheses. The packages are children in four hierarchies, @code{Ada},
18884 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
18885 GNAT-specific hierarchy.
18886
18887 Note that an application program should only use packages in one of these
18888 four hierarchies if the package is defined in the Ada Reference Manual,
18889 or is listed in this section of the GNAT Programmers Reference Manual.
18890 All other units should be considered internal implementation units and
18891 should not be directly @code{with}'ed by application code. The use of
18892 a @code{with} statement that references one of these internal implementation
18893 units makes an application potentially dependent on changes in versions
18894 of GNAT, and will generate a warning message.
18895
18896 @menu
18897 * Ada.Characters.Latin_9 (a-chlat9.ads)::
18898 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
18899 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
18900 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
18901 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
18902 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
18903 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
18904 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
18905 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
18906 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
18907 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
18908 * Ada.Command_Line.Environment (a-colien.ads)::
18909 * Ada.Command_Line.Remove (a-colire.ads)::
18910 * Ada.Command_Line.Response_File (a-clrefi.ads)::
18911 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
18912 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
18913 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
18914 * Ada.Exceptions.Traceback (a-exctra.ads)::
18915 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
18916 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
18917 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
18918 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
18919 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
18920 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
18921 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
18922 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
18923 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
18924 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
18925 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
18926 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
18927 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
18928 * GNAT.Altivec (g-altive.ads)::
18929 * GNAT.Altivec.Conversions (g-altcon.ads)::
18930 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
18931 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
18932 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
18933 * GNAT.Array_Split (g-arrspl.ads)::
18934 * GNAT.AWK (g-awk.ads)::
18935 * GNAT.Bounded_Buffers (g-boubuf.ads)::
18936 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
18937 * GNAT.Bubble_Sort (g-bubsor.ads)::
18938 * GNAT.Bubble_Sort_A (g-busora.ads)::
18939 * GNAT.Bubble_Sort_G (g-busorg.ads)::
18940 * GNAT.Byte_Order_Mark (g-byorma.ads)::
18941 * GNAT.Byte_Swapping (g-bytswa.ads)::
18942 * GNAT.Calendar (g-calend.ads)::
18943 * GNAT.Calendar.Time_IO (g-catiio.ads)::
18944 * GNAT.Case_Util (g-casuti.ads)::
18945 * GNAT.CGI (g-cgi.ads)::
18946 * GNAT.CGI.Cookie (g-cgicoo.ads)::
18947 * GNAT.CGI.Debug (g-cgideb.ads)::
18948 * GNAT.Command_Line (g-comlin.ads)::
18949 * GNAT.Compiler_Version (g-comver.ads)::
18950 * GNAT.Ctrl_C (g-ctrl_c.ads)::
18951 * GNAT.CRC32 (g-crc32.ads)::
18952 * GNAT.Current_Exception (g-curexc.ads)::
18953 * GNAT.Debug_Pools (g-debpoo.ads)::
18954 * GNAT.Debug_Utilities (g-debuti.ads)::
18955 * GNAT.Decode_String (g-decstr.ads)::
18956 * GNAT.Decode_UTF8_String (g-deutst.ads)::
18957 * GNAT.Directory_Operations (g-dirope.ads)::
18958 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
18959 * GNAT.Dynamic_HTables (g-dynhta.ads)::
18960 * GNAT.Dynamic_Tables (g-dyntab.ads)::
18961 * GNAT.Encode_String (g-encstr.ads)::
18962 * GNAT.Encode_UTF8_String (g-enutst.ads)::
18963 * GNAT.Exception_Actions (g-excact.ads)::
18964 * GNAT.Exception_Traces (g-exctra.ads)::
18965 * GNAT.Exceptions (g-except.ads)::
18966 * GNAT.Expect (g-expect.ads)::
18967 * GNAT.Expect.TTY (g-exptty.ads)::
18968 * GNAT.Float_Control (g-flocon.ads)::
18969 * GNAT.Formatted_String (g-forstr.ads)::
18970 * GNAT.Heap_Sort (g-heasor.ads)::
18971 * GNAT.Heap_Sort_A (g-hesora.ads)::
18972 * GNAT.Heap_Sort_G (g-hesorg.ads)::
18973 * GNAT.HTable (g-htable.ads)::
18974 * GNAT.IO (g-io.ads)::
18975 * GNAT.IO_Aux (g-io_aux.ads)::
18976 * GNAT.Lock_Files (g-locfil.ads)::
18977 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
18978 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
18979 * GNAT.MD5 (g-md5.ads)::
18980 * GNAT.Memory_Dump (g-memdum.ads)::
18981 * GNAT.Most_Recent_Exception (g-moreex.ads)::
18982 * GNAT.OS_Lib (g-os_lib.ads)::
18983 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
18984 * GNAT.Random_Numbers (g-rannum.ads)::
18985 * GNAT.Regexp (g-regexp.ads)::
18986 * GNAT.Registry (g-regist.ads)::
18987 * GNAT.Regpat (g-regpat.ads)::
18988 * GNAT.Rewrite_Data (g-rewdat.ads)::
18989 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
18990 * GNAT.Semaphores (g-semaph.ads)::
18991 * GNAT.Serial_Communications (g-sercom.ads)::
18992 * GNAT.SHA1 (g-sha1.ads)::
18993 * GNAT.SHA224 (g-sha224.ads)::
18994 * GNAT.SHA256 (g-sha256.ads)::
18995 * GNAT.SHA384 (g-sha384.ads)::
18996 * GNAT.SHA512 (g-sha512.ads)::
18997 * GNAT.Signals (g-signal.ads)::
18998 * GNAT.Sockets (g-socket.ads)::
18999 * GNAT.Source_Info (g-souinf.ads)::
19000 * GNAT.Spelling_Checker (g-speche.ads)::
19001 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
19002 * GNAT.Spitbol.Patterns (g-spipat.ads)::
19003 * GNAT.Spitbol (g-spitbo.ads)::
19004 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
19005 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
19006 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
19007 * GNAT.SSE (g-sse.ads)::
19008 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
19009 * GNAT.Strings (g-string.ads)::
19010 * GNAT.String_Split (g-strspl.ads)::
19011 * GNAT.Table (g-table.ads)::
19012 * GNAT.Task_Lock (g-tasloc.ads)::
19013 * GNAT.Threads (g-thread.ads)::
19014 * GNAT.Time_Stamp (g-timsta.ads)::
19015 * GNAT.Traceback (g-traceb.ads)::
19016 * GNAT.Traceback.Symbolic (g-trasym.ads)::
19017 * GNAT.UTF_32 (g-utf_32.ads)::
19018 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
19019 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
19020 * GNAT.Wide_String_Split (g-wistsp.ads)::
19021 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
19022 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
19023 * Interfaces.C.Extensions (i-cexten.ads)::
19024 * Interfaces.C.Streams (i-cstrea.ads)::
19025 * Interfaces.Packed_Decimal (i-pacdec.ads)::
19026 * Interfaces.VxWorks (i-vxwork.ads)::
19027 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
19028 * System.Address_Image (s-addima.ads)::
19029 * System.Assertions (s-assert.ads)::
19030 * System.Memory (s-memory.ads)::
19031 * System.Multiprocessors (s-multip.ads)::
19032 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
19033 * System.Partition_Interface (s-parint.ads)::
19034 * System.Pool_Global (s-pooglo.ads)::
19035 * System.Pool_Local (s-pooloc.ads)::
19036 * System.Restrictions (s-restri.ads)::
19037 * System.Rident (s-rident.ads)::
19038 * System.Strings.Stream_Ops (s-ststop.ads)::
19039 * System.Unsigned_Types (s-unstyp.ads)::
19040 * System.Wch_Cnv (s-wchcnv.ads)::
19041 * System.Wch_Con (s-wchcon.ads)::
19042 @end menu
19043
19044 @node Ada.Characters.Latin_9 (a-chlat9.ads)
19045 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
19046 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
19047 @cindex Latin_9 constants for Character
19048
19049 @noindent
19050 This child of @code{Ada.Characters}
19051 provides a set of definitions corresponding to those in the
19052 RM-defined package @code{Ada.Characters.Latin_1} but with the
19053 few modifications required for @code{Latin-9}
19054 The provision of such a package
19055 is specifically authorized by the Ada Reference Manual
19056 (RM A.3.3(27)).
19057
19058 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
19059 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
19060 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
19061 @cindex Latin_1 constants for Wide_Character
19062
19063 @noindent
19064 This child of @code{Ada.Characters}
19065 provides a set of definitions corresponding to those in the
19066 RM-defined package @code{Ada.Characters.Latin_1} but with the
19067 types of the constants being @code{Wide_Character}
19068 instead of @code{Character}. The provision of such a package
19069 is specifically authorized by the Ada Reference Manual
19070 (RM A.3.3(27)).
19071
19072 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
19073 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
19074 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
19075 @cindex Latin_9 constants for Wide_Character
19076
19077 @noindent
19078 This child of @code{Ada.Characters}
19079 provides a set of definitions corresponding to those in the
19080 GNAT defined package @code{Ada.Characters.Latin_9} but with the
19081 types of the constants being @code{Wide_Character}
19082 instead of @code{Character}. The provision of such a package
19083 is specifically authorized by the Ada Reference Manual
19084 (RM A.3.3(27)).
19085
19086 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
19087 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
19088 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
19089 @cindex Latin_1 constants for Wide_Wide_Character
19090
19091 @noindent
19092 This child of @code{Ada.Characters}
19093 provides a set of definitions corresponding to those in the
19094 RM-defined package @code{Ada.Characters.Latin_1} but with the
19095 types of the constants being @code{Wide_Wide_Character}
19096 instead of @code{Character}. The provision of such a package
19097 is specifically authorized by the Ada Reference Manual
19098 (RM A.3.3(27)).
19099
19100 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
19101 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
19102 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
19103 @cindex Latin_9 constants for Wide_Wide_Character
19104
19105 @noindent
19106 This child of @code{Ada.Characters}
19107 provides a set of definitions corresponding to those in the
19108 GNAT defined package @code{Ada.Characters.Latin_9} but with the
19109 types of the constants being @code{Wide_Wide_Character}
19110 instead of @code{Character}. The provision of such a package
19111 is specifically authorized by the Ada Reference Manual
19112 (RM A.3.3(27)).
19113
19114 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
19115 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
19116 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
19117 @cindex Formal container for doubly linked lists
19118
19119 @noindent
19120 This child of @code{Ada.Containers} defines a modified version of the
19121 Ada 2005 container for doubly linked lists, meant to facilitate formal
19122 verification of code using such containers. The specification of this
19123 unit is compatible with SPARK 2014.
19124
19125 Note that although this container was designed with formal verification
19126 in mind, it may well be generally useful in that it is a simplified more
19127 efficient version than the one defined in the standard. In particular it
19128 does not have the complex overhead required to detect cursor tampering.
19129
19130 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
19131 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
19132 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
19133 @cindex Formal container for hashed maps
19134
19135 @noindent
19136 This child of @code{Ada.Containers} defines a modified version of the
19137 Ada 2005 container for hashed maps, meant to facilitate formal
19138 verification of code using such containers. The specification of this
19139 unit is compatible with SPARK 2014.
19140
19141 Note that although this container was designed with formal verification
19142 in mind, it may well be generally useful in that it is a simplified more
19143 efficient version than the one defined in the standard. In particular it
19144 does not have the complex overhead required to detect cursor tampering.
19145
19146 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
19147 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
19148 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
19149 @cindex Formal container for hashed sets
19150
19151 @noindent
19152 This child of @code{Ada.Containers} defines a modified version of the
19153 Ada 2005 container for hashed sets, meant to facilitate formal
19154 verification of code using such containers. The specification of this
19155 unit is compatible with SPARK 2014.
19156
19157 Note that although this container was designed with formal verification
19158 in mind, it may well be generally useful in that it is a simplified more
19159 efficient version than the one defined in the standard. In particular it
19160 does not have the complex overhead required to detect cursor tampering.
19161
19162 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
19163 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
19164 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
19165 @cindex Formal container for ordered maps
19166
19167 @noindent
19168 This child of @code{Ada.Containers} defines a modified version of the
19169 Ada 2005 container for ordered maps, meant to facilitate formal
19170 verification of code using such containers. The specification of this
19171 unit is compatible with SPARK 2014.
19172
19173 Note that although this container was designed with formal verification
19174 in mind, it may well be generally useful in that it is a simplified more
19175 efficient version than the one defined in the standard. In particular it
19176 does not have the complex overhead required to detect cursor tampering.
19177
19178 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
19179 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
19180 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
19181 @cindex Formal container for ordered sets
19182
19183 @noindent
19184 This child of @code{Ada.Containers} defines a modified version of the
19185 Ada 2005 container for ordered sets, meant to facilitate formal
19186 verification of code using such containers. The specification of this
19187 unit is compatible with SPARK 2014.
19188
19189 Note that although this container was designed with formal verification
19190 in mind, it may well be generally useful in that it is a simplified more
19191 efficient version than the one defined in the standard. In particular it
19192 does not have the complex overhead required to detect cursor tampering.
19193
19194 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
19195 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
19196 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
19197 @cindex Formal container for vectors
19198
19199 @noindent
19200 This child of @code{Ada.Containers} defines a modified version of the
19201 Ada 2005 container for vectors, meant to facilitate formal
19202 verification of code using such containers. The specification of this
19203 unit is compatible with SPARK 2014.
19204
19205 Note that although this container was designed with formal verification
19206 in mind, it may well be generally useful in that it is a simplified more
19207 efficient version than the one defined in the standard. In particular it
19208 does not have the complex overhead required to detect cursor tampering.
19209
19210 @node Ada.Command_Line.Environment (a-colien.ads)
19211 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
19212 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
19213 @cindex Environment entries
19214
19215 @noindent
19216 This child of @code{Ada.Command_Line}
19217 provides a mechanism for obtaining environment values on systems
19218 where this concept makes sense.
19219
19220 @node Ada.Command_Line.Remove (a-colire.ads)
19221 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
19222 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
19223 @cindex Removing command line arguments
19224 @cindex Command line, argument removal
19225
19226 @noindent
19227 This child of @code{Ada.Command_Line}
19228 provides a mechanism for logically removing
19229 arguments from the argument list. Once removed, an argument is not visible
19230 to further calls on the subprograms in @code{Ada.Command_Line} will not
19231 see the removed argument.
19232
19233 @node Ada.Command_Line.Response_File (a-clrefi.ads)
19234 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
19235 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
19236 @cindex Response file for command line
19237 @cindex Command line, response file
19238 @cindex Command line, handling long command lines
19239
19240 @noindent
19241 This child of @code{Ada.Command_Line} provides a mechanism facilities for
19242 getting command line arguments from a text file, called a "response file".
19243 Using a response file allow passing a set of arguments to an executable longer
19244 than the maximum allowed by the system on the command line.
19245
19246 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
19247 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
19248 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
19249 @cindex C Streams, Interfacing with Direct_IO
19250
19251 @noindent
19252 This package provides subprograms that allow interfacing between
19253 C streams and @code{Direct_IO}. The stream identifier can be
19254 extracted from a file opened on the Ada side, and an Ada file
19255 can be constructed from a stream opened on the C side.
19256
19257 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
19258 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
19259 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
19260 @cindex Null_Occurrence, testing for
19261
19262 @noindent
19263 This child subprogram provides a way of testing for the null
19264 exception occurrence (@code{Null_Occurrence}) without raising
19265 an exception.
19266
19267 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
19268 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
19269 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
19270 @cindex Null_Occurrence, testing for
19271
19272 @noindent
19273 This child subprogram is used for handling otherwise unhandled
19274 exceptions (hence the name last chance), and perform clean ups before
19275 terminating the program. Note that this subprogram never returns.
19276
19277 @node Ada.Exceptions.Traceback (a-exctra.ads)
19278 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
19279 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
19280 @cindex Traceback for Exception Occurrence
19281
19282 @noindent
19283 This child package provides the subprogram (@code{Tracebacks}) to
19284 give a traceback array of addresses based on an exception
19285 occurrence.
19286
19287 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
19288 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
19289 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
19290 @cindex C Streams, Interfacing with Sequential_IO
19291
19292 @noindent
19293 This package provides subprograms that allow interfacing between
19294 C streams and @code{Sequential_IO}. The stream identifier can be
19295 extracted from a file opened on the Ada side, and an Ada file
19296 can be constructed from a stream opened on the C side.
19297
19298 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
19299 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
19300 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
19301 @cindex C Streams, Interfacing with Stream_IO
19302
19303 @noindent
19304 This package provides subprograms that allow interfacing between
19305 C streams and @code{Stream_IO}. The stream identifier can be
19306 extracted from a file opened on the Ada side, and an Ada file
19307 can be constructed from a stream opened on the C side.
19308
19309 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
19310 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
19311 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
19312 @cindex @code{Unbounded_String}, IO support
19313 @cindex @code{Text_IO}, extensions for unbounded strings
19314
19315 @noindent
19316 This package provides subprograms for Text_IO for unbounded
19317 strings, avoiding the necessity for an intermediate operation
19318 with ordinary strings.
19319
19320 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
19321 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
19322 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
19323 @cindex @code{Unbounded_Wide_String}, IO support
19324 @cindex @code{Text_IO}, extensions for unbounded wide strings
19325
19326 @noindent
19327 This package provides subprograms for Text_IO for unbounded
19328 wide strings, avoiding the necessity for an intermediate operation
19329 with ordinary wide strings.
19330
19331 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
19332 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
19333 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
19334 @cindex @code{Unbounded_Wide_Wide_String}, IO support
19335 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
19336
19337 @noindent
19338 This package provides subprograms for Text_IO for unbounded
19339 wide wide strings, avoiding the necessity for an intermediate operation
19340 with ordinary wide wide strings.
19341
19342 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
19343 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
19344 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
19345 @cindex C Streams, Interfacing with @code{Text_IO}
19346
19347 @noindent
19348 This package provides subprograms that allow interfacing between
19349 C streams and @code{Text_IO}. The stream identifier can be
19350 extracted from a file opened on the Ada side, and an Ada file
19351 can be constructed from a stream opened on the C side.
19352
19353 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
19354 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
19355 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
19356 @cindex @code{Text_IO} resetting standard files
19357
19358 @noindent
19359 This procedure is used to reset the status of the standard files used
19360 by Ada.Text_IO. This is useful in a situation (such as a restart in an
19361 embedded application) where the status of the files may change during
19362 execution (for example a standard input file may be redefined to be
19363 interactive).
19364
19365 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
19366 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
19367 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
19368 @cindex Unicode categorization, Wide_Character
19369
19370 @noindent
19371 This package provides subprograms that allow categorization of
19372 Wide_Character values according to Unicode categories.
19373
19374 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
19375 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
19376 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
19377 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
19378
19379 @noindent
19380 This package provides subprograms that allow interfacing between
19381 C streams and @code{Wide_Text_IO}. The stream identifier can be
19382 extracted from a file opened on the Ada side, and an Ada file
19383 can be constructed from a stream opened on the C side.
19384
19385 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
19386 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
19387 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
19388 @cindex @code{Wide_Text_IO} resetting standard files
19389
19390 @noindent
19391 This procedure is used to reset the status of the standard files used
19392 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
19393 embedded application) where the status of the files may change during
19394 execution (for example a standard input file may be redefined to be
19395 interactive).
19396
19397 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
19398 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
19399 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
19400 @cindex Unicode categorization, Wide_Wide_Character
19401
19402 @noindent
19403 This package provides subprograms that allow categorization of
19404 Wide_Wide_Character values according to Unicode categories.
19405
19406 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
19407 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
19408 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
19409 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
19410
19411 @noindent
19412 This package provides subprograms that allow interfacing between
19413 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
19414 extracted from a file opened on the Ada side, and an Ada file
19415 can be constructed from a stream opened on the C side.
19416
19417 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
19418 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
19419 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
19420 @cindex @code{Wide_Wide_Text_IO} resetting standard files
19421
19422 @noindent
19423 This procedure is used to reset the status of the standard files used
19424 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
19425 restart in an embedded application) where the status of the files may
19426 change during execution (for example a standard input file may be
19427 redefined to be interactive).
19428
19429 @node GNAT.Altivec (g-altive.ads)
19430 @section @code{GNAT.Altivec} (@file{g-altive.ads})
19431 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
19432 @cindex AltiVec
19433
19434 @noindent
19435 This is the root package of the GNAT AltiVec binding. It provides
19436 definitions of constants and types common to all the versions of the
19437 binding.
19438
19439 @node GNAT.Altivec.Conversions (g-altcon.ads)
19440 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
19441 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
19442 @cindex AltiVec
19443
19444 @noindent
19445 This package provides the Vector/View conversion routines.
19446
19447 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
19448 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
19449 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
19450 @cindex AltiVec
19451
19452 @noindent
19453 This package exposes the Ada interface to the AltiVec operations on
19454 vector objects. A soft emulation is included by default in the GNAT
19455 library. The hard binding is provided as a separate package. This unit
19456 is common to both bindings.
19457
19458 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
19459 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
19460 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
19461 @cindex AltiVec
19462
19463 @noindent
19464 This package exposes the various vector types part of the Ada binding
19465 to AltiVec facilities.
19466
19467 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
19468 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19469 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
19470 @cindex AltiVec
19471
19472 @noindent
19473 This package provides public 'View' data types from/to which private
19474 vector representations can be converted via
19475 GNAT.Altivec.Conversions. This allows convenient access to individual
19476 vector elements and provides a simple way to initialize vector
19477 objects.
19478
19479 @node GNAT.Array_Split (g-arrspl.ads)
19480 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19481 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
19482 @cindex Array splitter
19483
19484 @noindent
19485 Useful array-manipulation routines: given a set of separators, split
19486 an array wherever the separators appear, and provide direct access
19487 to the resulting slices.
19488
19489 @node GNAT.AWK (g-awk.ads)
19490 @section @code{GNAT.AWK} (@file{g-awk.ads})
19491 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
19492 @cindex Parsing
19493 @cindex AWK
19494
19495 @noindent
19496 Provides AWK-like parsing functions, with an easy interface for parsing one
19497 or more files containing formatted data. The file is viewed as a database
19498 where each record is a line and a field is a data element in this line.
19499
19500 @node GNAT.Bounded_Buffers (g-boubuf.ads)
19501 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19502 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
19503 @cindex Parsing
19504 @cindex Bounded Buffers
19505
19506 @noindent
19507 Provides a concurrent generic bounded buffer abstraction. Instances are
19508 useful directly or as parts of the implementations of other abstractions,
19509 such as mailboxes.
19510
19511 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
19512 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19513 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
19514 @cindex Parsing
19515 @cindex Mailboxes
19516
19517 @noindent
19518 Provides a thread-safe asynchronous intertask mailbox communication facility.
19519
19520 @node GNAT.Bubble_Sort (g-bubsor.ads)
19521 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19522 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
19523 @cindex Sorting
19524 @cindex Bubble sort
19525
19526 @noindent
19527 Provides a general implementation of bubble sort usable for sorting arbitrary
19528 data items. Exchange and comparison procedures are provided by passing
19529 access-to-procedure values.
19530
19531 @node GNAT.Bubble_Sort_A (g-busora.ads)
19532 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19533 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
19534 @cindex Sorting
19535 @cindex Bubble sort
19536
19537 @noindent
19538 Provides a general implementation of bubble sort usable for sorting arbitrary
19539 data items. Move and comparison procedures are provided by passing
19540 access-to-procedure values. This is an older version, retained for
19541 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
19542
19543 @node GNAT.Bubble_Sort_G (g-busorg.ads)
19544 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19545 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
19546 @cindex Sorting
19547 @cindex Bubble sort
19548
19549 @noindent
19550 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
19551 are provided as generic parameters, this improves efficiency, especially
19552 if the procedures can be inlined, at the expense of duplicating code for
19553 multiple instantiations.
19554
19555 @node GNAT.Byte_Order_Mark (g-byorma.ads)
19556 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19557 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
19558 @cindex UTF-8 representation
19559 @cindex Wide characte representations
19560
19561 @noindent
19562 Provides a routine which given a string, reads the start of the string to
19563 see whether it is one of the standard byte order marks (BOM's) which signal
19564 the encoding of the string. The routine includes detection of special XML
19565 sequences for various UCS input formats.
19566
19567 @node GNAT.Byte_Swapping (g-bytswa.ads)
19568 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19569 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
19570 @cindex Byte swapping
19571 @cindex Endianness
19572
19573 @noindent
19574 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
19575 Machine-specific implementations are available in some cases.
19576
19577 @node GNAT.Calendar (g-calend.ads)
19578 @section @code{GNAT.Calendar} (@file{g-calend.ads})
19579 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
19580 @cindex @code{Calendar}
19581
19582 @noindent
19583 Extends the facilities provided by @code{Ada.Calendar} to include handling
19584 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
19585 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
19586 C @code{timeval} format.
19587
19588 @node GNAT.Calendar.Time_IO (g-catiio.ads)
19589 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19590 @cindex @code{Calendar}
19591 @cindex Time
19592 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
19593
19594 @node GNAT.Case_Util (g-casuti.ads)
19595 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
19596 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
19597 @cindex Casing utilities
19598 @cindex Character handling (@code{GNAT.Case_Util})
19599
19600 @noindent
19601 A set of simple routines for handling upper and lower casing of strings
19602 without the overhead of the full casing tables
19603 in @code{Ada.Characters.Handling}.
19604
19605 @node GNAT.CGI (g-cgi.ads)
19606 @section @code{GNAT.CGI} (@file{g-cgi.ads})
19607 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
19608 @cindex CGI (Common Gateway Interface)
19609
19610 @noindent
19611 This is a package for interfacing a GNAT program with a Web server via the
19612 Common Gateway Interface (CGI)@. Basically this package parses the CGI
19613 parameters, which are a set of key/value pairs sent by the Web server. It
19614 builds a table whose index is the key and provides some services to deal
19615 with this table.
19616
19617 @node GNAT.CGI.Cookie (g-cgicoo.ads)
19618 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19619 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
19620 @cindex CGI (Common Gateway Interface) cookie support
19621 @cindex Cookie support in CGI
19622
19623 @noindent
19624 This is a package to interface a GNAT program with a Web server via the
19625 Common Gateway Interface (CGI). It exports services to deal with Web
19626 cookies (piece of information kept in the Web client software).
19627
19628 @node GNAT.CGI.Debug (g-cgideb.ads)
19629 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19630 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
19631 @cindex CGI (Common Gateway Interface) debugging
19632
19633 @noindent
19634 This is a package to help debugging CGI (Common Gateway Interface)
19635 programs written in Ada.
19636
19637 @node GNAT.Command_Line (g-comlin.ads)
19638 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
19639 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
19640 @cindex Command line
19641
19642 @noindent
19643 Provides a high level interface to @code{Ada.Command_Line} facilities,
19644 including the ability to scan for named switches with optional parameters
19645 and expand file names using wild card notations.
19646
19647 @node GNAT.Compiler_Version (g-comver.ads)
19648 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19649 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
19650 @cindex Compiler Version
19651 @cindex Version, of compiler
19652
19653 @noindent
19654 Provides a routine for obtaining the version of the compiler used to
19655 compile the program. More accurately this is the version of the binder
19656 used to bind the program (this will normally be the same as the version
19657 of the compiler if a consistent tool set is used to compile all units
19658 of a partition).
19659
19660 @node GNAT.Ctrl_C (g-ctrl_c.ads)
19661 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19662 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
19663 @cindex Interrupt
19664
19665 @noindent
19666 Provides a simple interface to handle Ctrl-C keyboard events.
19667
19668 @node GNAT.CRC32 (g-crc32.ads)
19669 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
19670 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
19671 @cindex CRC32
19672 @cindex Cyclic Redundancy Check
19673
19674 @noindent
19675 This package implements the CRC-32 algorithm. For a full description
19676 of this algorithm see
19677 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
19678 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
19679 Aug.@: 1988. Sarwate, D.V@.
19680
19681 @node GNAT.Current_Exception (g-curexc.ads)
19682 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19683 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
19684 @cindex Current exception
19685 @cindex Exception retrieval
19686
19687 @noindent
19688 Provides access to information on the current exception that has been raised
19689 without the need for using the Ada 95 / Ada 2005 exception choice parameter
19690 specification syntax.
19691 This is particularly useful in simulating typical facilities for
19692 obtaining information about exceptions provided by Ada 83 compilers.
19693
19694 @node GNAT.Debug_Pools (g-debpoo.ads)
19695 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19696 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
19697 @cindex Debugging
19698 @cindex Debug pools
19699 @cindex Memory corruption debugging
19700
19701 @noindent
19702 Provide a debugging storage pools that helps tracking memory corruption
19703 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
19704 @value{EDITION} User's Guide}.
19705
19706 @node GNAT.Debug_Utilities (g-debuti.ads)
19707 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19708 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
19709 @cindex Debugging
19710
19711 @noindent
19712 Provides a few useful utilities for debugging purposes, including conversion
19713 to and from string images of address values. Supports both C and Ada formats
19714 for hexadecimal literals.
19715
19716 @node GNAT.Decode_String (g-decstr.ads)
19717 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
19718 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
19719 @cindex Decoding strings
19720 @cindex String decoding
19721 @cindex Wide character encoding
19722 @cindex UTF-8
19723 @cindex Unicode
19724
19725 @noindent
19726 A generic package providing routines for decoding wide character and wide wide
19727 character strings encoded as sequences of 8-bit characters using a specified
19728 encoding method. Includes validation routines, and also routines for stepping
19729 to next or previous encoded character in an encoded string.
19730 Useful in conjunction with Unicode character coding. Note there is a
19731 preinstantiation for UTF-8. See next entry.
19732
19733 @node GNAT.Decode_UTF8_String (g-deutst.ads)
19734 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19735 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
19736 @cindex Decoding strings
19737 @cindex Decoding UTF-8 strings
19738 @cindex UTF-8 string decoding
19739 @cindex Wide character decoding
19740 @cindex UTF-8
19741 @cindex Unicode
19742
19743 @noindent
19744 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
19745
19746 @node GNAT.Directory_Operations (g-dirope.ads)
19747 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19748 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
19749 @cindex Directory operations
19750
19751 @noindent
19752 Provides a set of routines for manipulating directories, including changing
19753 the current directory, making new directories, and scanning the files in a
19754 directory.
19755
19756 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
19757 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19758 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
19759 @cindex Directory operations iteration
19760
19761 @noindent
19762 A child unit of GNAT.Directory_Operations providing additional operations
19763 for iterating through directories.
19764
19765 @node GNAT.Dynamic_HTables (g-dynhta.ads)
19766 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19767 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
19768 @cindex Hash tables
19769
19770 @noindent
19771 A generic implementation of hash tables that can be used to hash arbitrary
19772 data. Provided in two forms, a simple form with built in hash functions,
19773 and a more complex form in which the hash function is supplied.
19774
19775 @noindent
19776 This package provides a facility similar to that of @code{GNAT.HTable},
19777 except that this package declares a type that can be used to define
19778 dynamic instances of the hash table, while an instantiation of
19779 @code{GNAT.HTable} creates a single instance of the hash table.
19780
19781 @node GNAT.Dynamic_Tables (g-dyntab.ads)
19782 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19783 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
19784 @cindex Table implementation
19785 @cindex Arrays, extendable
19786
19787 @noindent
19788 A generic package providing a single dimension array abstraction where the
19789 length of the array can be dynamically modified.
19790
19791 @noindent
19792 This package provides a facility similar to that of @code{GNAT.Table},
19793 except that this package declares a type that can be used to define
19794 dynamic instances of the table, while an instantiation of
19795 @code{GNAT.Table} creates a single instance of the table type.
19796
19797 @node GNAT.Encode_String (g-encstr.ads)
19798 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
19799 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
19800 @cindex Encoding strings
19801 @cindex String encoding
19802 @cindex Wide character encoding
19803 @cindex UTF-8
19804 @cindex Unicode
19805
19806 @noindent
19807 A generic package providing routines for encoding wide character and wide
19808 wide character strings as sequences of 8-bit characters using a specified
19809 encoding method. Useful in conjunction with Unicode character coding.
19810 Note there is a preinstantiation for UTF-8. See next entry.
19811
19812 @node GNAT.Encode_UTF8_String (g-enutst.ads)
19813 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19814 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
19815 @cindex Encoding strings
19816 @cindex Encoding UTF-8 strings
19817 @cindex UTF-8 string encoding
19818 @cindex Wide character encoding
19819 @cindex UTF-8
19820 @cindex Unicode
19821
19822 @noindent
19823 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
19824
19825 @node GNAT.Exception_Actions (g-excact.ads)
19826 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19827 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
19828 @cindex Exception actions
19829
19830 @noindent
19831 Provides callbacks when an exception is raised. Callbacks can be registered
19832 for specific exceptions, or when any exception is raised. This
19833 can be used for instance to force a core dump to ease debugging.
19834
19835 @node GNAT.Exception_Traces (g-exctra.ads)
19836 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19837 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
19838 @cindex Exception traces
19839 @cindex Debugging
19840
19841 @noindent
19842 Provides an interface allowing to control automatic output upon exception
19843 occurrences.
19844
19845 @node GNAT.Exceptions (g-except.ads)
19846 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
19847 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
19848 @cindex Exceptions, Pure
19849 @cindex Pure packages, exceptions
19850
19851 @noindent
19852 Normally it is not possible to raise an exception with
19853 a message from a subprogram in a pure package, since the
19854 necessary types and subprograms are in @code{Ada.Exceptions}
19855 which is not a pure unit. @code{GNAT.Exceptions} provides a
19856 facility for getting around this limitation for a few
19857 predefined exceptions, and for example allow raising
19858 @code{Constraint_Error} with a message from a pure subprogram.
19859
19860 @node GNAT.Expect (g-expect.ads)
19861 @section @code{GNAT.Expect} (@file{g-expect.ads})
19862 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
19863
19864 @noindent
19865 Provides a set of subprograms similar to what is available
19866 with the standard Tcl Expect tool.
19867 It allows you to easily spawn and communicate with an external process.
19868 You can send commands or inputs to the process, and compare the output
19869 with some expected regular expression. Currently @code{GNAT.Expect}
19870 is implemented on all native GNAT ports except for OpenVMS@.
19871 It is not implemented for cross ports, and in particular is not
19872 implemented for VxWorks or LynxOS@.
19873
19874 @node GNAT.Expect.TTY (g-exptty.ads)
19875 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
19876 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
19877
19878 @noindent
19879 As GNAT.Expect but using pseudo-terminal.
19880 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
19881 ports except for OpenVMS@. It is not implemented for cross ports, and
19882 in particular is not implemented for VxWorks or LynxOS@.
19883
19884 @node GNAT.Float_Control (g-flocon.ads)
19885 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
19886 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
19887 @cindex Floating-Point Processor
19888
19889 @noindent
19890 Provides an interface for resetting the floating-point processor into the
19891 mode required for correct semantic operation in Ada. Some third party
19892 library calls may cause this mode to be modified, and the Reset procedure
19893 in this package can be used to reestablish the required mode.
19894
19895 @node GNAT.Formatted_String (g-forstr.ads)
19896 @section @code{GNAT.Formatted_String} (@file{g-forstr.ads})
19897 @cindex @code{GNAT.Formatted_String} (@file{g-forstr.ads})
19898 @cindex Formatted String
19899
19900 @noindent
19901 Provides support for C/C++ printf() formatted strings. The format is
19902 copied from the printf() routine and should therefore gives identical
19903 output. Some generic routines are provided to be able to use types
19904 derived from Integer, Float or enumerations as values for the
19905 formatted string.
19906
19907 @node GNAT.Heap_Sort (g-heasor.ads)
19908 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
19909 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
19910 @cindex Sorting
19911
19912 @noindent
19913 Provides a general implementation of heap sort usable for sorting arbitrary
19914 data items. Exchange and comparison procedures are provided by passing
19915 access-to-procedure values. The algorithm used is a modified heap sort
19916 that performs approximately N*log(N) comparisons in the worst case.
19917
19918 @node GNAT.Heap_Sort_A (g-hesora.ads)
19919 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
19920 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
19921 @cindex Sorting
19922
19923 @noindent
19924 Provides a general implementation of heap sort usable for sorting arbitrary
19925 data items. Move and comparison procedures are provided by passing
19926 access-to-procedure values. The algorithm used is a modified heap sort
19927 that performs approximately N*log(N) comparisons in the worst case.
19928 This differs from @code{GNAT.Heap_Sort} in having a less convenient
19929 interface, but may be slightly more efficient.
19930
19931 @node GNAT.Heap_Sort_G (g-hesorg.ads)
19932 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
19933 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
19934 @cindex Sorting
19935
19936 @noindent
19937 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
19938 are provided as generic parameters, this improves efficiency, especially
19939 if the procedures can be inlined, at the expense of duplicating code for
19940 multiple instantiations.
19941
19942 @node GNAT.HTable (g-htable.ads)
19943 @section @code{GNAT.HTable} (@file{g-htable.ads})
19944 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
19945 @cindex Hash tables
19946
19947 @noindent
19948 A generic implementation of hash tables that can be used to hash arbitrary
19949 data. Provides two approaches, one a simple static approach, and the other
19950 allowing arbitrary dynamic hash tables.
19951
19952 @node GNAT.IO (g-io.ads)
19953 @section @code{GNAT.IO} (@file{g-io.ads})
19954 @cindex @code{GNAT.IO} (@file{g-io.ads})
19955 @cindex Simple I/O
19956 @cindex Input/Output facilities
19957
19958 @noindent
19959 A simple preelaborable input-output package that provides a subset of
19960 simple Text_IO functions for reading characters and strings from
19961 Standard_Input, and writing characters, strings and integers to either
19962 Standard_Output or Standard_Error.
19963
19964 @node GNAT.IO_Aux (g-io_aux.ads)
19965 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
19966 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
19967 @cindex Text_IO
19968 @cindex Input/Output facilities
19969
19970 Provides some auxiliary functions for use with Text_IO, including a test
19971 for whether a file exists, and functions for reading a line of text.
19972
19973 @node GNAT.Lock_Files (g-locfil.ads)
19974 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
19975 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
19976 @cindex File locking
19977 @cindex Locking using files
19978
19979 @noindent
19980 Provides a general interface for using files as locks. Can be used for
19981 providing program level synchronization.
19982
19983 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
19984 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
19985 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
19986 @cindex Random number generation
19987
19988 @noindent
19989 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
19990 a modified version of the Blum-Blum-Shub generator.
19991
19992 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
19993 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
19994 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
19995 @cindex Random number generation
19996
19997 @noindent
19998 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
19999 a modified version of the Blum-Blum-Shub generator.
20000
20001 @node GNAT.MD5 (g-md5.ads)
20002 @section @code{GNAT.MD5} (@file{g-md5.ads})
20003 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
20004 @cindex Message Digest MD5
20005
20006 @noindent
20007 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
20008
20009 @node GNAT.Memory_Dump (g-memdum.ads)
20010 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
20011 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
20012 @cindex Dump Memory
20013
20014 @noindent
20015 Provides a convenient routine for dumping raw memory to either the
20016 standard output or standard error files. Uses GNAT.IO for actual
20017 output.
20018
20019 @node GNAT.Most_Recent_Exception (g-moreex.ads)
20020 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
20021 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
20022 @cindex Exception, obtaining most recent
20023
20024 @noindent
20025 Provides access to the most recently raised exception. Can be used for
20026 various logging purposes, including duplicating functionality of some
20027 Ada 83 implementation dependent extensions.
20028
20029 @node GNAT.OS_Lib (g-os_lib.ads)
20030 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
20031 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
20032 @cindex Operating System interface
20033 @cindex Spawn capability
20034
20035 @noindent
20036 Provides a range of target independent operating system interface functions,
20037 including time/date management, file operations, subprocess management,
20038 including a portable spawn procedure, and access to environment variables
20039 and error return codes.
20040
20041 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
20042 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
20043 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
20044 @cindex Hash functions
20045
20046 @noindent
20047 Provides a generator of static minimal perfect hash functions. No
20048 collisions occur and each item can be retrieved from the table in one
20049 probe (perfect property). The hash table size corresponds to the exact
20050 size of the key set and no larger (minimal property). The key set has to
20051 be know in advance (static property). The hash functions are also order
20052 preserving. If w2 is inserted after w1 in the generator, their
20053 hashcode are in the same order. These hashing functions are very
20054 convenient for use with realtime applications.
20055
20056 @node GNAT.Random_Numbers (g-rannum.ads)
20057 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
20058 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
20059 @cindex Random number generation
20060
20061 @noindent
20062 Provides random number capabilities which extend those available in the
20063 standard Ada library and are more convenient to use.
20064
20065 @node GNAT.Regexp (g-regexp.ads)
20066 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
20067 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
20068 @cindex Regular expressions
20069 @cindex Pattern matching
20070
20071 @noindent
20072 A simple implementation of regular expressions, using a subset of regular
20073 expression syntax copied from familiar Unix style utilities. This is the
20074 simplest of the three pattern matching packages provided, and is particularly
20075 suitable for ``file globbing'' applications.
20076
20077 @node GNAT.Registry (g-regist.ads)
20078 @section @code{GNAT.Registry} (@file{g-regist.ads})
20079 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
20080 @cindex Windows Registry
20081
20082 @noindent
20083 This is a high level binding to the Windows registry. It is possible to
20084 do simple things like reading a key value, creating a new key. For full
20085 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
20086 package provided with the Win32Ada binding
20087
20088 @node GNAT.Regpat (g-regpat.ads)
20089 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
20090 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
20091 @cindex Regular expressions
20092 @cindex Pattern matching
20093
20094 @noindent
20095 A complete implementation of Unix-style regular expression matching, copied
20096 from the original V7 style regular expression library written in C by
20097 Henry Spencer (and binary compatible with this C library).
20098
20099 @node GNAT.Rewrite_Data (g-rewdat.ads)
20100 @section @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
20101 @cindex @code{GNAT.Rewrite_Data} (@file{g-rewdat.ads})
20102 @cindex Rewrite data
20103
20104 @noindent
20105 A unit to rewrite on-the-fly string occurrences in a stream of
20106 data. The implementation has a very minimal memory footprint as the
20107 full content to be processed is not loaded into memory all at once. This makes
20108 this interface usable for large files or socket streams.
20109
20110 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
20111 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
20112 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
20113 @cindex Secondary Stack Info
20114
20115 @noindent
20116 Provide the capability to query the high water mark of the current task's
20117 secondary stack.
20118
20119 @node GNAT.Semaphores (g-semaph.ads)
20120 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
20121 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
20122 @cindex Semaphores
20123
20124 @noindent
20125 Provides classic counting and binary semaphores using protected types.
20126
20127 @node GNAT.Serial_Communications (g-sercom.ads)
20128 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
20129 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
20130 @cindex Serial_Communications
20131
20132 @noindent
20133 Provides a simple interface to send and receive data over a serial
20134 port. This is only supported on GNU/Linux and Windows.
20135
20136 @node GNAT.SHA1 (g-sha1.ads)
20137 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
20138 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
20139 @cindex Secure Hash Algorithm SHA-1
20140
20141 @noindent
20142 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
20143 and RFC 3174.
20144
20145 @node GNAT.SHA224 (g-sha224.ads)
20146 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
20147 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
20148 @cindex Secure Hash Algorithm SHA-224
20149
20150 @noindent
20151 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
20152
20153 @node GNAT.SHA256 (g-sha256.ads)
20154 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
20155 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
20156 @cindex Secure Hash Algorithm SHA-256
20157
20158 @noindent
20159 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
20160
20161 @node GNAT.SHA384 (g-sha384.ads)
20162 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
20163 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
20164 @cindex Secure Hash Algorithm SHA-384
20165
20166 @noindent
20167 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
20168
20169 @node GNAT.SHA512 (g-sha512.ads)
20170 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
20171 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
20172 @cindex Secure Hash Algorithm SHA-512
20173
20174 @noindent
20175 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
20176
20177 @node GNAT.Signals (g-signal.ads)
20178 @section @code{GNAT.Signals} (@file{g-signal.ads})
20179 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
20180 @cindex Signals
20181
20182 @noindent
20183 Provides the ability to manipulate the blocked status of signals on supported
20184 targets.
20185
20186 @node GNAT.Sockets (g-socket.ads)
20187 @section @code{GNAT.Sockets} (@file{g-socket.ads})
20188 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
20189 @cindex Sockets
20190
20191 @noindent
20192 A high level and portable interface to develop sockets based applications.
20193 This package is based on the sockets thin binding found in
20194 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
20195 on all native GNAT ports except for OpenVMS@. It is not implemented
20196 for the LynxOS@ cross port.
20197
20198 @node GNAT.Source_Info (g-souinf.ads)
20199 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
20200 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
20201 @cindex Source Information
20202
20203 @noindent
20204 Provides subprograms that give access to source code information known at
20205 compile time, such as the current file name and line number. Also provides
20206 subprograms yielding the date and time of the current compilation (like the
20207 C macros @code{__DATE__} and @code{__TIME__})
20208
20209 @node GNAT.Spelling_Checker (g-speche.ads)
20210 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
20211 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
20212 @cindex Spell checking
20213
20214 @noindent
20215 Provides a function for determining whether one string is a plausible
20216 near misspelling of another string.
20217
20218 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
20219 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
20220 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
20221 @cindex Spell checking
20222
20223 @noindent
20224 Provides a generic function that can be instantiated with a string type for
20225 determining whether one string is a plausible near misspelling of another
20226 string.
20227
20228 @node GNAT.Spitbol.Patterns (g-spipat.ads)
20229 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
20230 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
20231 @cindex SPITBOL pattern matching
20232 @cindex Pattern matching
20233
20234 @noindent
20235 A complete implementation of SNOBOL4 style pattern matching. This is the
20236 most elaborate of the pattern matching packages provided. It fully duplicates
20237 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
20238 efficient algorithm developed by Robert Dewar for the SPITBOL system.
20239
20240 @node GNAT.Spitbol (g-spitbo.ads)
20241 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
20242 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
20243 @cindex SPITBOL interface
20244
20245 @noindent
20246 The top level package of the collection of SPITBOL-style functionality, this
20247 package provides basic SNOBOL4 string manipulation functions, such as
20248 Pad, Reverse, Trim, Substr capability, as well as a generic table function
20249 useful for constructing arbitrary mappings from strings in the style of
20250 the SNOBOL4 TABLE function.
20251
20252 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
20253 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
20254 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
20255 @cindex Sets of strings
20256 @cindex SPITBOL Tables
20257
20258 @noindent
20259 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
20260 for type @code{Standard.Boolean}, giving an implementation of sets of
20261 string values.
20262
20263 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
20264 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
20265 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
20266 @cindex Integer maps
20267 @cindex Maps
20268 @cindex SPITBOL Tables
20269
20270 @noindent
20271 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
20272 for type @code{Standard.Integer}, giving an implementation of maps
20273 from string to integer values.
20274
20275 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
20276 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
20277 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
20278 @cindex String maps
20279 @cindex Maps
20280 @cindex SPITBOL Tables
20281
20282 @noindent
20283 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
20284 a variable length string type, giving an implementation of general
20285 maps from strings to strings.
20286
20287 @node GNAT.SSE (g-sse.ads)
20288 @section @code{GNAT.SSE} (@file{g-sse.ads})
20289 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
20290
20291 @noindent
20292 Root of a set of units aimed at offering Ada bindings to a subset of
20293 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
20294 targets. It exposes vector component types together with a general
20295 introduction to the binding contents and use.
20296
20297 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
20298 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
20299 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
20300
20301 @noindent
20302 SSE vector types for use with SSE related intrinsics.
20303
20304 @node GNAT.Strings (g-string.ads)
20305 @section @code{GNAT.Strings} (@file{g-string.ads})
20306 @cindex @code{GNAT.Strings} (@file{g-string.ads})
20307
20308 @noindent
20309 Common String access types and related subprograms. Basically it
20310 defines a string access and an array of string access types.
20311
20312 @node GNAT.String_Split (g-strspl.ads)
20313 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
20314 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
20315 @cindex String splitter
20316
20317 @noindent
20318 Useful string manipulation routines: given a set of separators, split
20319 a string wherever the separators appear, and provide direct access
20320 to the resulting slices. This package is instantiated from
20321 @code{GNAT.Array_Split}.
20322
20323 @node GNAT.Table (g-table.ads)
20324 @section @code{GNAT.Table} (@file{g-table.ads})
20325 @cindex @code{GNAT.Table} (@file{g-table.ads})
20326 @cindex Table implementation
20327 @cindex Arrays, extendable
20328
20329 @noindent
20330 A generic package providing a single dimension array abstraction where the
20331 length of the array can be dynamically modified.
20332
20333 @noindent
20334 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
20335 except that this package declares a single instance of the table type,
20336 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
20337 used to define dynamic instances of the table.
20338
20339 @node GNAT.Task_Lock (g-tasloc.ads)
20340 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
20341 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
20342 @cindex Task synchronization
20343 @cindex Task locking
20344 @cindex Locking
20345
20346 @noindent
20347 A very simple facility for locking and unlocking sections of code using a
20348 single global task lock. Appropriate for use in situations where contention
20349 between tasks is very rarely expected.
20350
20351 @node GNAT.Threads (g-thread.ads)
20352 @section @code{GNAT.Threads} (@file{g-thread.ads})
20353 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
20354 @cindex Foreign threads
20355 @cindex Threads, foreign
20356
20357 @noindent
20358 Provides facilities for dealing with foreign threads which need to be known
20359 by the GNAT run-time system. Consult the documentation of this package for
20360 further details if your program has threads that are created by a non-Ada
20361 environment which then accesses Ada code.
20362
20363 @node GNAT.Time_Stamp (g-timsta.ads)
20364 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
20365 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
20366 @cindex Time stamp
20367 @cindex Current time
20368
20369 @noindent
20370 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
20371 represents the current date and time in ISO 8601 format. This is a very simple
20372 routine with minimal code and there are no dependencies on any other unit.
20373
20374 @node GNAT.Traceback (g-traceb.ads)
20375 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
20376 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
20377 @cindex Trace back facilities
20378
20379 @noindent
20380 Provides a facility for obtaining non-symbolic traceback information, useful
20381 in various debugging situations.
20382
20383 @node GNAT.Traceback.Symbolic (g-trasym.ads)
20384 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
20385 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
20386 @cindex Trace back facilities
20387
20388 @node GNAT.UTF_32 (g-utf_32.ads)
20389 @section @code{GNAT.UTF_32} (@file{g-table.ads})
20390 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
20391 @cindex Wide character codes
20392
20393 @noindent
20394 This is a package intended to be used in conjunction with the
20395 @code{Wide_Character} type in Ada 95 and the
20396 @code{Wide_Wide_Character} type in Ada 2005 (available
20397 in @code{GNAT} in Ada 2005 mode). This package contains
20398 Unicode categorization routines, as well as lexical
20399 categorization routines corresponding to the Ada 2005
20400 lexical rules for identifiers and strings, and also a
20401 lower case to upper case fold routine corresponding to
20402 the Ada 2005 rules for identifier equivalence.
20403
20404 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
20405 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
20406 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
20407 @cindex Spell checking
20408
20409 @noindent
20410 Provides a function for determining whether one wide wide string is a plausible
20411 near misspelling of another wide wide string, where the strings are represented
20412 using the UTF_32_String type defined in System.Wch_Cnv.
20413
20414 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
20415 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
20416 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
20417 @cindex Spell checking
20418
20419 @noindent
20420 Provides a function for determining whether one wide string is a plausible
20421 near misspelling of another wide string.
20422
20423 @node GNAT.Wide_String_Split (g-wistsp.ads)
20424 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
20425 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
20426 @cindex Wide_String splitter
20427
20428 @noindent
20429 Useful wide string manipulation routines: given a set of separators, split
20430 a wide string wherever the separators appear, and provide direct access
20431 to the resulting slices. This package is instantiated from
20432 @code{GNAT.Array_Split}.
20433
20434 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
20435 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
20436 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
20437 @cindex Spell checking
20438
20439 @noindent
20440 Provides a function for determining whether one wide wide string is a plausible
20441 near misspelling of another wide wide string.
20442
20443 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
20444 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
20445 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
20446 @cindex Wide_Wide_String splitter
20447
20448 @noindent
20449 Useful wide wide string manipulation routines: given a set of separators, split
20450 a wide wide string wherever the separators appear, and provide direct access
20451 to the resulting slices. This package is instantiated from
20452 @code{GNAT.Array_Split}.
20453
20454 @node Interfaces.C.Extensions (i-cexten.ads)
20455 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
20456 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
20457
20458 @noindent
20459 This package contains additional C-related definitions, intended
20460 for use with either manually or automatically generated bindings
20461 to C libraries.
20462
20463 @node Interfaces.C.Streams (i-cstrea.ads)
20464 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
20465 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
20466 @cindex C streams, interfacing
20467
20468 @noindent
20469 This package is a binding for the most commonly used operations
20470 on C streams.
20471
20472 @node Interfaces.Packed_Decimal (i-pacdec.ads)
20473 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20474 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
20475 @cindex IBM Packed Format
20476 @cindex Packed Decimal
20477
20478 @noindent
20479 This package provides a set of routines for conversions to and
20480 from a packed decimal format compatible with that used on IBM
20481 mainframes.
20482
20483 @node Interfaces.VxWorks (i-vxwork.ads)
20484 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20485 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
20486 @cindex Interfacing to VxWorks
20487 @cindex VxWorks, interfacing
20488
20489 @noindent
20490 This package provides a limited binding to the VxWorks API.
20491 In particular, it interfaces with the
20492 VxWorks hardware interrupt facilities.
20493
20494 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
20495 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20496 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
20497 @cindex Interfacing to VxWorks' I/O
20498 @cindex VxWorks, I/O interfacing
20499 @cindex VxWorks, Get_Immediate
20500 @cindex Get_Immediate, VxWorks
20501
20502 @noindent
20503 This package provides a binding to the ioctl (IO/Control)
20504 function of VxWorks, defining a set of option values and
20505 function codes. A particular use of this package is
20506 to enable the use of Get_Immediate under VxWorks.
20507
20508 @node System.Address_Image (s-addima.ads)
20509 @section @code{System.Address_Image} (@file{s-addima.ads})
20510 @cindex @code{System.Address_Image} (@file{s-addima.ads})
20511 @cindex Address image
20512 @cindex Image, of an address
20513
20514 @noindent
20515 This function provides a useful debugging
20516 function that gives an (implementation dependent)
20517 string which identifies an address.
20518
20519 @node System.Assertions (s-assert.ads)
20520 @section @code{System.Assertions} (@file{s-assert.ads})
20521 @cindex @code{System.Assertions} (@file{s-assert.ads})
20522 @cindex Assertions
20523 @cindex Assert_Failure, exception
20524
20525 @noindent
20526 This package provides the declaration of the exception raised
20527 by an run-time assertion failure, as well as the routine that
20528 is used internally to raise this assertion.
20529
20530 @node System.Memory (s-memory.ads)
20531 @section @code{System.Memory} (@file{s-memory.ads})
20532 @cindex @code{System.Memory} (@file{s-memory.ads})
20533 @cindex Memory allocation
20534
20535 @noindent
20536 This package provides the interface to the low level routines used
20537 by the generated code for allocation and freeing storage for the
20538 default storage pool (analogous to the C routines malloc and free.
20539 It also provides a reallocation interface analogous to the C routine
20540 realloc. The body of this unit may be modified to provide alternative
20541 allocation mechanisms for the default pool, and in addition, direct
20542 calls to this unit may be made for low level allocation uses (for
20543 example see the body of @code{GNAT.Tables}).
20544
20545 @node System.Multiprocessors (s-multip.ads)
20546 @section @code{System.Multiprocessors} (@file{s-multip.ads})
20547 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
20548 @cindex Multiprocessor interface
20549 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20550 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20551 technically an implementation-defined addition).
20552
20553 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
20554 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20555 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
20556 @cindex Multiprocessor interface
20557 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
20558 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
20559 technically an implementation-defined addition).
20560
20561 @node System.Partition_Interface (s-parint.ads)
20562 @section @code{System.Partition_Interface} (@file{s-parint.ads})
20563 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
20564 @cindex Partition interfacing functions
20565
20566 @noindent
20567 This package provides facilities for partition interfacing. It
20568 is used primarily in a distribution context when using Annex E
20569 with @code{GLADE}.
20570
20571 @node System.Pool_Global (s-pooglo.ads)
20572 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
20573 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
20574 @cindex Storage pool, global
20575 @cindex Global storage pool
20576
20577 @noindent
20578 This package provides a storage pool that is equivalent to the default
20579 storage pool used for access types for which no pool is specifically
20580 declared. It uses malloc/free to allocate/free and does not attempt to
20581 do any automatic reclamation.
20582
20583 @node System.Pool_Local (s-pooloc.ads)
20584 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
20585 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
20586 @cindex Storage pool, local
20587 @cindex Local storage pool
20588
20589 @noindent
20590 This package provides a storage pool that is intended for use with locally
20591 defined access types. It uses malloc/free for allocate/free, and maintains
20592 a list of allocated blocks, so that all storage allocated for the pool can
20593 be freed automatically when the pool is finalized.
20594
20595 @node System.Restrictions (s-restri.ads)
20596 @section @code{System.Restrictions} (@file{s-restri.ads})
20597 @cindex @code{System.Restrictions} (@file{s-restri.ads})
20598 @cindex Run-time restrictions access
20599
20600 @noindent
20601 This package provides facilities for accessing at run time
20602 the status of restrictions specified at compile time for
20603 the partition. Information is available both with regard
20604 to actual restrictions specified, and with regard to
20605 compiler determined information on which restrictions
20606 are violated by one or more packages in the partition.
20607
20608 @node System.Rident (s-rident.ads)
20609 @section @code{System.Rident} (@file{s-rident.ads})
20610 @cindex @code{System.Rident} (@file{s-rident.ads})
20611 @cindex Restrictions definitions
20612
20613 @noindent
20614 This package provides definitions of the restrictions
20615 identifiers supported by GNAT, and also the format of
20616 the restrictions provided in package System.Restrictions.
20617 It is not normally necessary to @code{with} this generic package
20618 since the necessary instantiation is included in
20619 package System.Restrictions.
20620
20621 @node System.Strings.Stream_Ops (s-ststop.ads)
20622 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20623 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
20624 @cindex Stream operations
20625 @cindex String stream operations
20626
20627 @noindent
20628 This package provides a set of stream subprograms for standard string types.
20629 It is intended primarily to support implicit use of such subprograms when
20630 stream attributes are applied to string types, but the subprograms in this
20631 package can be used directly by application programs.
20632
20633 @node System.Unsigned_Types (s-unstyp.ads)
20634 @section @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20635 @cindex @code{System.Unsigned_Types} (@file{s-unstyp.ads})
20636
20637 @noindent
20638 This package contains definitions of standard unsigned types that
20639 correspond in size to the standard signed types declared in Standard,
20640 and (unlike the types in Interfaces) have corresponding names. It
20641 also contains some related definitions for other specialized types
20642 used by the compiler in connection with packed array types.
20643
20644 @node System.Wch_Cnv (s-wchcnv.ads)
20645 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20646 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
20647 @cindex Wide Character, Representation
20648 @cindex Wide String, Conversion
20649 @cindex Representation of wide characters
20650
20651 @noindent
20652 This package provides routines for converting between
20653 wide and wide wide characters and a representation as a value of type
20654 @code{Standard.String}, using a specified wide character
20655 encoding method. It uses definitions in
20656 package @code{System.Wch_Con}.
20657
20658 @node System.Wch_Con (s-wchcon.ads)
20659 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
20660 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
20661
20662 @noindent
20663 This package provides definitions and descriptions of
20664 the various methods used for encoding wide characters
20665 in ordinary strings. These definitions are used by
20666 the package @code{System.Wch_Cnv}.
20667
20668 @node Interfacing to Other Languages
20669 @chapter Interfacing to Other Languages
20670 @noindent
20671 The facilities in annex B of the Ada Reference Manual are fully
20672 implemented in GNAT, and in addition, a full interface to C++ is
20673 provided.
20674
20675 @menu
20676 * Interfacing to C::
20677 * Interfacing to C++::
20678 * Interfacing to COBOL::
20679 * Interfacing to Fortran::
20680 * Interfacing to non-GNAT Ada code::
20681 @end menu
20682
20683 @node Interfacing to C
20684 @section Interfacing to C
20685
20686 @noindent
20687 Interfacing to C with GNAT can use one of two approaches:
20688
20689 @itemize @bullet
20690 @item
20691 The types in the package @code{Interfaces.C} may be used.
20692 @item
20693 Standard Ada types may be used directly. This may be less portable to
20694 other compilers, but will work on all GNAT compilers, which guarantee
20695 correspondence between the C and Ada types.
20696 @end itemize
20697
20698 @noindent
20699 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
20700 effect, since this is the default. The following table shows the
20701 correspondence between Ada scalar types and the corresponding C types.
20702
20703 @table @code
20704 @item Integer
20705 @code{int}
20706 @item Short_Integer
20707 @code{short}
20708 @item Short_Short_Integer
20709 @code{signed char}
20710 @item Long_Integer
20711 @code{long}
20712 @item Long_Long_Integer
20713 @code{long long}
20714 @item Short_Float
20715 @code{float}
20716 @item Float
20717 @code{float}
20718 @item Long_Float
20719 @code{double}
20720 @item Long_Long_Float
20721 This is the longest floating-point type supported by the hardware.
20722 @end table
20723
20724 @noindent
20725 Additionally, there are the following general correspondences between Ada
20726 and C types:
20727 @itemize @bullet
20728 @item
20729 Ada enumeration types map to C enumeration types directly if pragma
20730 @code{Convention C} is specified, which causes them to have int
20731 length. Without pragma @code{Convention C}, Ada enumeration types map to
20732 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
20733 @code{int}, respectively) depending on the number of values passed.
20734 This is the only case in which pragma @code{Convention C} affects the
20735 representation of an Ada type.
20736
20737 @item
20738 Ada access types map to C pointers, except for the case of pointers to
20739 unconstrained types in Ada, which have no direct C equivalent.
20740
20741 @item
20742 Ada arrays map directly to C arrays.
20743
20744 @item
20745 Ada records map directly to C structures.
20746
20747 @item
20748 Packed Ada records map to C structures where all members are bit fields
20749 of the length corresponding to the @code{@var{type}'Size} value in Ada.
20750 @end itemize
20751
20752 @node Interfacing to C++
20753 @section Interfacing to C++
20754
20755 @noindent
20756 The interface to C++ makes use of the following pragmas, which are
20757 primarily intended to be constructed automatically using a binding generator
20758 tool, although it is possible to construct them by hand.
20759
20760 Using these pragmas it is possible to achieve complete
20761 inter-operability between Ada tagged types and C++ class definitions.
20762 See @ref{Implementation Defined Pragmas}, for more details.
20763
20764 @table @code
20765 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
20766 The argument denotes an entity in the current declarative region that is
20767 declared as a tagged or untagged record type. It indicates that the type
20768 corresponds to an externally declared C++ class type, and is to be laid
20769 out the same way that C++ would lay out the type.
20770
20771 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
20772 for backward compatibility but its functionality is available
20773 using pragma @code{Import} with @code{Convention} = @code{CPP}.
20774
20775 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
20776 This pragma identifies an imported function (imported in the usual way
20777 with pragma @code{Import}) as corresponding to a C++ constructor.
20778 @end table
20779
20780 A few restrictions are placed on the use of the @code{Access} attribute
20781 in conjunction with subprograms subject to convention @code{CPP}: the
20782 attribute may be used neither on primitive operations of a tagged
20783 record type with convention @code{CPP}, imported or not, nor on
20784 subprograms imported with pragma @code{CPP_Constructor}.
20785
20786 In addition, C++ exceptions are propagated and can be handled in an
20787 @code{others} choice of an exception handler. The corresponding Ada
20788 occurrence has no message, and the simple name of the exception identity
20789 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
20790 tasks works properly when such foreign exceptions are propagated.
20791
20792 It is also possible to import a C++ exception using the following syntax:
20793
20794 @smallexample @c ada
20795 LOCAL_NAME : exception;
20796 pragma Import (Cpp,
20797 [Entity =>] LOCAL_NAME,
20798 [External_Name =>] static_string_EXPRESSION);
20799 @end smallexample
20800
20801 @noindent
20802 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
20803 cover a specific C++ exception in an exception handler.
20804
20805 @node Interfacing to COBOL
20806 @section Interfacing to COBOL
20807
20808 @noindent
20809 Interfacing to COBOL is achieved as described in section B.4 of
20810 the Ada Reference Manual.
20811
20812 @node Interfacing to Fortran
20813 @section Interfacing to Fortran
20814
20815 @noindent
20816 Interfacing to Fortran is achieved as described in section B.5 of the
20817 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
20818 multi-dimensional array causes the array to be stored in column-major
20819 order as required for convenient interface to Fortran.
20820
20821 @node Interfacing to non-GNAT Ada code
20822 @section Interfacing to non-GNAT Ada code
20823
20824 It is possible to specify the convention @code{Ada} in a pragma
20825 @code{Import} or pragma @code{Export}. However this refers to
20826 the calling conventions used by GNAT, which may or may not be
20827 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
20828 compiler to allow interoperation.
20829
20830 If arguments types are kept simple, and if the foreign compiler generally
20831 follows system calling conventions, then it may be possible to integrate
20832 files compiled by other Ada compilers, provided that the elaboration
20833 issues are adequately addressed (for example by eliminating the
20834 need for any load time elaboration).
20835
20836 In particular, GNAT running on VMS is designed to
20837 be highly compatible with the DEC Ada 83 compiler, so this is one
20838 case in which it is possible to import foreign units of this type,
20839 provided that the data items passed are restricted to simple scalar
20840 values or simple record types without variants, or simple array
20841 types with fixed bounds.
20842
20843 @node Specialized Needs Annexes
20844 @chapter Specialized Needs Annexes
20845
20846 @noindent
20847 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
20848 required in all implementations. However, as described in this chapter,
20849 GNAT implements all of these annexes:
20850
20851 @table @asis
20852 @item Systems Programming (Annex C)
20853 The Systems Programming Annex is fully implemented.
20854
20855 @item Real-Time Systems (Annex D)
20856 The Real-Time Systems Annex is fully implemented.
20857
20858 @item Distributed Systems (Annex E)
20859 Stub generation is fully implemented in the GNAT compiler. In addition,
20860 a complete compatible PCS is available as part of the GLADE system,
20861 a separate product. When the two
20862 products are used in conjunction, this annex is fully implemented.
20863
20864 @item Information Systems (Annex F)
20865 The Information Systems annex is fully implemented.
20866
20867 @item Numerics (Annex G)
20868 The Numerics Annex is fully implemented.
20869
20870 @item Safety and Security / High-Integrity Systems (Annex H)
20871 The Safety and Security Annex (termed the High-Integrity Systems Annex
20872 in Ada 2005) is fully implemented.
20873 @end table
20874
20875 @node Implementation of Specific Ada Features
20876 @chapter Implementation of Specific Ada Features
20877
20878 @noindent
20879 This chapter describes the GNAT implementation of several Ada language
20880 facilities.
20881
20882 @menu
20883 * Machine Code Insertions::
20884 * GNAT Implementation of Tasking::
20885 * GNAT Implementation of Shared Passive Packages::
20886 * Code Generation for Array Aggregates::
20887 * The Size of Discriminated Records with Default Discriminants::
20888 * Strict Conformance to the Ada Reference Manual::
20889 @end menu
20890
20891 @node Machine Code Insertions
20892 @section Machine Code Insertions
20893 @cindex Machine Code insertions
20894
20895 @noindent
20896 Package @code{Machine_Code} provides machine code support as described
20897 in the Ada Reference Manual in two separate forms:
20898 @itemize @bullet
20899 @item
20900 Machine code statements, consisting of qualified expressions that
20901 fit the requirements of RM section 13.8.
20902 @item
20903 An intrinsic callable procedure, providing an alternative mechanism of
20904 including machine instructions in a subprogram.
20905 @end itemize
20906
20907 @noindent
20908 The two features are similar, and both are closely related to the mechanism
20909 provided by the asm instruction in the GNU C compiler. Full understanding
20910 and use of the facilities in this package requires understanding the asm
20911 instruction, see @ref{Extended Asm,,, gcc, Using the GNU Compiler
20912 Collection (GCC)}.
20913
20914 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
20915 semantic restrictions and effects as described below. Both are provided so
20916 that the procedure call can be used as a statement, and the function call
20917 can be used to form a code_statement.
20918
20919 Consider this C @code{asm} instruction:
20920 @smallexample
20921 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
20922 @end smallexample
20923
20924 @noindent
20925 The equivalent can be written for GNAT as:
20926
20927 @smallexample @c ada
20928 Asm ("fsinx %1 %0",
20929 My_Float'Asm_Output ("=f", result),
20930 My_Float'Asm_Input ("f", angle));
20931 @end smallexample
20932
20933 @noindent
20934 The first argument to @code{Asm} is the assembler template, and is
20935 identical to what is used in GNU C@. This string must be a static
20936 expression. The second argument is the output operand list. It is
20937 either a single @code{Asm_Output} attribute reference, or a list of such
20938 references enclosed in parentheses (technically an array aggregate of
20939 such references).
20940
20941 The @code{Asm_Output} attribute denotes a function that takes two
20942 parameters. The first is a string, the second is the name of a variable
20943 of the type designated by the attribute prefix. The first (string)
20944 argument is required to be a static expression and designates the
20945 constraint (@pxref{Constraints,,, gcc, Using the GNU Compiler
20946 Collection (GCC)})
20947 for the parameter (e.g.@: what kind of register is required). The second
20948 argument is the variable to be written or updated with the
20949 result. The possible values for constraint are the same as those used in
20950 the RTL, and are dependent on the configuration file used to build the
20951 GCC back end. If there are no output operands, then this argument may
20952 either be omitted, or explicitly given as @code{No_Output_Operands}.
20953 No support is provided for GNU C's symbolic names for output parameters.
20954
20955 The second argument of @code{@var{my_float}'Asm_Output} functions as
20956 though it were an @code{out} parameter, which is a little curious, but
20957 all names have the form of expressions, so there is no syntactic
20958 irregularity, even though normally functions would not be permitted
20959 @code{out} parameters. The third argument is the list of input
20960 operands. It is either a single @code{Asm_Input} attribute reference, or
20961 a list of such references enclosed in parentheses (technically an array
20962 aggregate of such references).
20963
20964 The @code{Asm_Input} attribute denotes a function that takes two
20965 parameters. The first is a string, the second is an expression of the
20966 type designated by the prefix. The first (string) argument is required
20967 to be a static expression, and is the constraint for the parameter,
20968 (e.g.@: what kind of register is required). The second argument is the
20969 value to be used as the input argument. The possible values for the
20970 constraint are the same as those used in the RTL, and are dependent on
20971 the configuration file used to built the GCC back end.
20972 No support is provided for GNU C's symbolic names for input parameters.
20973
20974 If there are no input operands, this argument may either be omitted, or
20975 explicitly given as @code{No_Input_Operands}. The fourth argument, not
20976 present in the above example, is a list of register names, called the
20977 @dfn{clobber} argument. This argument, if given, must be a static string
20978 expression, and is a space or comma separated list of names of registers
20979 that must be considered destroyed as a result of the @code{Asm} call. If
20980 this argument is the null string (the default value), then the code
20981 generator assumes that no additional registers are destroyed.
20982 In addition to registers, the special clobbers @code{memory} and
20983 @code{cc} as described in the GNU C docs are both supported.
20984
20985 The fifth argument, not present in the above example, called the
20986 @dfn{volatile} argument, is by default @code{False}. It can be set to
20987 the literal value @code{True} to indicate to the code generator that all
20988 optimizations with respect to the instruction specified should be
20989 suppressed, and in particular an instruction that has outputs
20990 will still be generated, even if none of the outputs are
20991 used. @xref{Volatile,,,
20992 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
20993 Generally it is strongly advisable to use Volatile for any ASM statement
20994 that is missing either input or output operands or to avoid unwanted
20995 optimizations. A warning is generated if this advice is not followed.
20996
20997 No support is provided for GNU C's @code{asm goto} feature.
20998
20999 The @code{Asm} subprograms may be used in two ways. First the procedure
21000 forms can be used anywhere a procedure call would be valid, and
21001 correspond to what the RM calls ``intrinsic'' routines. Such calls can
21002 be used to intersperse machine instructions with other Ada statements.
21003 Second, the function forms, which return a dummy value of the limited
21004 private type @code{Asm_Insn}, can be used in code statements, and indeed
21005 this is the only context where such calls are allowed. Code statements
21006 appear as aggregates of the form:
21007
21008 @smallexample @c ada
21009 Asm_Insn'(Asm (@dots{}));
21010 Asm_Insn'(Asm_Volatile (@dots{}));
21011 @end smallexample
21012
21013 @noindent
21014 In accordance with RM rules, such code statements are allowed only
21015 within subprograms whose entire body consists of such statements. It is
21016 not permissible to intermix such statements with other Ada statements.
21017
21018 Typically the form using intrinsic procedure calls is more convenient
21019 and more flexible. The code statement form is provided to meet the RM
21020 suggestion that such a facility should be made available. The following
21021 is the exact syntax of the call to @code{Asm}. As usual, if named notation
21022 is used, the arguments may be given in arbitrary order, following the
21023 normal rules for use of positional and named arguments:
21024
21025 @smallexample
21026 ASM_CALL ::= Asm (
21027 [Template =>] static_string_EXPRESSION
21028 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
21029 [,[Inputs =>] INPUT_OPERAND_LIST ]
21030 [,[Clobber =>] static_string_EXPRESSION ]
21031 [,[Volatile =>] static_boolean_EXPRESSION] )
21032
21033 OUTPUT_OPERAND_LIST ::=
21034 [PREFIX.]No_Output_Operands
21035 | OUTPUT_OPERAND_ATTRIBUTE
21036 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
21037
21038 OUTPUT_OPERAND_ATTRIBUTE ::=
21039 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
21040
21041 INPUT_OPERAND_LIST ::=
21042 [PREFIX.]No_Input_Operands
21043 | INPUT_OPERAND_ATTRIBUTE
21044 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
21045
21046 INPUT_OPERAND_ATTRIBUTE ::=
21047 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
21048 @end smallexample
21049
21050 @noindent
21051 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
21052 are declared in the package @code{Machine_Code} and must be referenced
21053 according to normal visibility rules. In particular if there is no
21054 @code{use} clause for this package, then appropriate package name
21055 qualification is required.
21056
21057 @node GNAT Implementation of Tasking
21058 @section GNAT Implementation of Tasking
21059
21060 @noindent
21061 This chapter outlines the basic GNAT approach to tasking (in particular,
21062 a multi-layered library for portability) and discusses issues related
21063 to compliance with the Real-Time Systems Annex.
21064
21065 @menu
21066 * Mapping Ada Tasks onto the Underlying Kernel Threads::
21067 * Ensuring Compliance with the Real-Time Annex::
21068 @end menu
21069
21070 @node Mapping Ada Tasks onto the Underlying Kernel Threads
21071 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
21072
21073 @noindent
21074 GNAT's run-time support comprises two layers:
21075
21076 @itemize @bullet
21077 @item GNARL (GNAT Run-time Layer)
21078 @item GNULL (GNAT Low-level Library)
21079 @end itemize
21080
21081 @noindent
21082 In GNAT, Ada's tasking services rely on a platform and OS independent
21083 layer known as GNARL@. This code is responsible for implementing the
21084 correct semantics of Ada's task creation, rendezvous, protected
21085 operations etc.
21086
21087 GNARL decomposes Ada's tasking semantics into simpler lower level
21088 operations such as create a thread, set the priority of a thread,
21089 yield, create a lock, lock/unlock, etc. The spec for these low-level
21090 operations constitutes GNULLI, the GNULL Interface. This interface is
21091 directly inspired from the POSIX real-time API@.
21092
21093 If the underlying executive or OS implements the POSIX standard
21094 faithfully, the GNULL Interface maps as is to the services offered by
21095 the underlying kernel. Otherwise, some target dependent glue code maps
21096 the services offered by the underlying kernel to the semantics expected
21097 by GNARL@.
21098
21099 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
21100 key point is that each Ada task is mapped on a thread in the underlying
21101 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
21102
21103 In addition Ada task priorities map onto the underlying thread priorities.
21104 Mapping Ada tasks onto the underlying kernel threads has several advantages:
21105
21106 @itemize @bullet
21107 @item
21108 The underlying scheduler is used to schedule the Ada tasks. This
21109 makes Ada tasks as efficient as kernel threads from a scheduling
21110 standpoint.
21111
21112 @item
21113 Interaction with code written in C containing threads is eased
21114 since at the lowest level Ada tasks and C threads map onto the same
21115 underlying kernel concept.
21116
21117 @item
21118 When an Ada task is blocked during I/O the remaining Ada tasks are
21119 able to proceed.
21120
21121 @item
21122 On multiprocessor systems Ada tasks can execute in parallel.
21123 @end itemize
21124
21125 @noindent
21126 Some threads libraries offer a mechanism to fork a new process, with the
21127 child process duplicating the threads from the parent.
21128 GNAT does not
21129 support this functionality when the parent contains more than one task.
21130 @cindex Forking a new process
21131
21132 @node Ensuring Compliance with the Real-Time Annex
21133 @subsection Ensuring Compliance with the Real-Time Annex
21134 @cindex Real-Time Systems Annex compliance
21135
21136 @noindent
21137 Although mapping Ada tasks onto
21138 the underlying threads has significant advantages, it does create some
21139 complications when it comes to respecting the scheduling semantics
21140 specified in the real-time annex (Annex D).
21141
21142 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
21143 scheduling policy states:
21144
21145 @quotation
21146 @emph{When the active priority of a ready task that is not running
21147 changes, or the setting of its base priority takes effect, the
21148 task is removed from the ready queue for its old active priority
21149 and is added at the tail of the ready queue for its new active
21150 priority, except in the case where the active priority is lowered
21151 due to the loss of inherited priority, in which case the task is
21152 added at the head of the ready queue for its new active priority.}
21153 @end quotation
21154
21155 @noindent
21156 While most kernels do put tasks at the end of the priority queue when
21157 a task changes its priority, (which respects the main
21158 FIFO_Within_Priorities requirement), almost none keep a thread at the
21159 beginning of its priority queue when its priority drops from the loss
21160 of inherited priority.
21161
21162 As a result most vendors have provided incomplete Annex D implementations.
21163
21164 The GNAT run-time, has a nice cooperative solution to this problem
21165 which ensures that accurate FIFO_Within_Priorities semantics are
21166 respected.
21167
21168 The principle is as follows. When an Ada task T is about to start
21169 running, it checks whether some other Ada task R with the same
21170 priority as T has been suspended due to the loss of priority
21171 inheritance. If this is the case, T yields and is placed at the end of
21172 its priority queue. When R arrives at the front of the queue it
21173 executes.
21174
21175 Note that this simple scheme preserves the relative order of the tasks
21176 that were ready to execute in the priority queue where R has been
21177 placed at the end.
21178
21179 @node GNAT Implementation of Shared Passive Packages
21180 @section GNAT Implementation of Shared Passive Packages
21181 @cindex Shared passive packages
21182
21183 @noindent
21184 GNAT fully implements the pragma @code{Shared_Passive} for
21185 @cindex pragma @code{Shared_Passive}
21186 the purpose of designating shared passive packages.
21187 This allows the use of passive partitions in the
21188 context described in the Ada Reference Manual; i.e., for communication
21189 between separate partitions of a distributed application using the
21190 features in Annex E.
21191 @cindex Annex E
21192 @cindex Distribution Systems Annex
21193
21194 However, the implementation approach used by GNAT provides for more
21195 extensive usage as follows:
21196
21197 @table @emph
21198 @item Communication between separate programs
21199
21200 This allows separate programs to access the data in passive
21201 partitions, using protected objects for synchronization where
21202 needed. The only requirement is that the two programs have a
21203 common shared file system. It is even possible for programs
21204 running on different machines with different architectures
21205 (e.g.@: different endianness) to communicate via the data in
21206 a passive partition.
21207
21208 @item Persistence between program runs
21209
21210 The data in a passive package can persist from one run of a
21211 program to another, so that a later program sees the final
21212 values stored by a previous run of the same program.
21213
21214 @end table
21215
21216 @noindent
21217 The implementation approach used is to store the data in files. A
21218 separate stream file is created for each object in the package, and
21219 an access to an object causes the corresponding file to be read or
21220 written.
21221
21222 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
21223 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
21224 set to the directory to be used for these files.
21225 The files in this directory
21226 have names that correspond to their fully qualified names. For
21227 example, if we have the package
21228
21229 @smallexample @c ada
21230 package X is
21231 pragma Shared_Passive (X);
21232 Y : Integer;
21233 Z : Float;
21234 end X;
21235 @end smallexample
21236
21237 @noindent
21238 and the environment variable is set to @code{/stemp/}, then the files created
21239 will have the names:
21240
21241 @smallexample
21242 /stemp/x.y
21243 /stemp/x.z
21244 @end smallexample
21245
21246 @noindent
21247 These files are created when a value is initially written to the object, and
21248 the files are retained until manually deleted. This provides the persistence
21249 semantics. If no file exists, it means that no partition has assigned a value
21250 to the variable; in this case the initial value declared in the package
21251 will be used. This model ensures that there are no issues in synchronizing
21252 the elaboration process, since elaboration of passive packages elaborates the
21253 initial values, but does not create the files.
21254
21255 The files are written using normal @code{Stream_IO} access.
21256 If you want to be able
21257 to communicate between programs or partitions running on different
21258 architectures, then you should use the XDR versions of the stream attribute
21259 routines, since these are architecture independent.
21260
21261 If active synchronization is required for access to the variables in the
21262 shared passive package, then as described in the Ada Reference Manual, the
21263 package may contain protected objects used for this purpose. In this case
21264 a lock file (whose name is @file{___lock} (three underscores)
21265 is created in the shared memory directory.
21266 @cindex @file{___lock} file (for shared passive packages)
21267 This is used to provide the required locking
21268 semantics for proper protected object synchronization.
21269
21270 As of January 2003, GNAT supports shared passive packages on all platforms
21271 except for OpenVMS.
21272
21273 @node Code Generation for Array Aggregates
21274 @section Code Generation for Array Aggregates
21275
21276 @menu
21277 * Static constant aggregates with static bounds::
21278 * Constant aggregates with unconstrained nominal types::
21279 * Aggregates with static bounds::
21280 * Aggregates with non-static bounds::
21281 * Aggregates in assignment statements::
21282 @end menu
21283
21284 @noindent
21285 Aggregates have a rich syntax and allow the user to specify the values of
21286 complex data structures by means of a single construct. As a result, the
21287 code generated for aggregates can be quite complex and involve loops, case
21288 statements and multiple assignments. In the simplest cases, however, the
21289 compiler will recognize aggregates whose components and constraints are
21290 fully static, and in those cases the compiler will generate little or no
21291 executable code. The following is an outline of the code that GNAT generates
21292 for various aggregate constructs. For further details, you will find it
21293 useful to examine the output produced by the -gnatG flag to see the expanded
21294 source that is input to the code generator. You may also want to examine
21295 the assembly code generated at various levels of optimization.
21296
21297 The code generated for aggregates depends on the context, the component values,
21298 and the type. In the context of an object declaration the code generated is
21299 generally simpler than in the case of an assignment. As a general rule, static
21300 component values and static subtypes also lead to simpler code.
21301
21302 @node Static constant aggregates with static bounds
21303 @subsection Static constant aggregates with static bounds
21304
21305 @noindent
21306 For the declarations:
21307 @smallexample @c ada
21308 type One_Dim is array (1..10) of integer;
21309 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
21310 @end smallexample
21311
21312 @noindent
21313 GNAT generates no executable code: the constant ar0 is placed in static memory.
21314 The same is true for constant aggregates with named associations:
21315
21316 @smallexample @c ada
21317 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
21318 Cr3 : constant One_Dim := (others => 7777);
21319 @end smallexample
21320
21321 @noindent
21322 The same is true for multidimensional constant arrays such as:
21323
21324 @smallexample @c ada
21325 type two_dim is array (1..3, 1..3) of integer;
21326 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
21327 @end smallexample
21328
21329 @noindent
21330 The same is true for arrays of one-dimensional arrays: the following are
21331 static:
21332
21333 @smallexample @c ada
21334 type ar1b is array (1..3) of boolean;
21335 type ar_ar is array (1..3) of ar1b;
21336 None : constant ar1b := (others => false); -- fully static
21337 None2 : constant ar_ar := (1..3 => None); -- fully static
21338 @end smallexample
21339
21340 @noindent
21341 However, for multidimensional aggregates with named associations, GNAT will
21342 generate assignments and loops, even if all associations are static. The
21343 following two declarations generate a loop for the first dimension, and
21344 individual component assignments for the second dimension:
21345
21346 @smallexample @c ada
21347 Zero1: constant two_dim := (1..3 => (1..3 => 0));
21348 Zero2: constant two_dim := (others => (others => 0));
21349 @end smallexample
21350
21351 @node Constant aggregates with unconstrained nominal types
21352 @subsection Constant aggregates with unconstrained nominal types
21353
21354 @noindent
21355 In such cases the aggregate itself establishes the subtype, so that
21356 associations with @code{others} cannot be used. GNAT determines the
21357 bounds for the actual subtype of the aggregate, and allocates the
21358 aggregate statically as well. No code is generated for the following:
21359
21360 @smallexample @c ada
21361 type One_Unc is array (natural range <>) of integer;
21362 Cr_Unc : constant One_Unc := (12,24,36);
21363 @end smallexample
21364
21365 @node Aggregates with static bounds
21366 @subsection Aggregates with static bounds
21367
21368 @noindent
21369 In all previous examples the aggregate was the initial (and immutable) value
21370 of a constant. If the aggregate initializes a variable, then code is generated
21371 for it as a combination of individual assignments and loops over the target
21372 object. The declarations
21373
21374 @smallexample @c ada
21375 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
21376 Cr_Var2 : One_Dim := (others > -1);
21377 @end smallexample
21378
21379 @noindent
21380 generate the equivalent of
21381
21382 @smallexample @c ada
21383 Cr_Var1 (1) := 2;
21384 Cr_Var1 (2) := 3;
21385 Cr_Var1 (3) := 5;
21386 Cr_Var1 (4) := 11;
21387
21388 for I in Cr_Var2'range loop
21389 Cr_Var2 (I) := -1;
21390 end loop;
21391 @end smallexample
21392
21393 @node Aggregates with non-static bounds
21394 @subsection Aggregates with non-static bounds
21395
21396 @noindent
21397 If the bounds of the aggregate are not statically compatible with the bounds
21398 of the nominal subtype of the target, then constraint checks have to be
21399 generated on the bounds. For a multidimensional array, constraint checks may
21400 have to be applied to sub-arrays individually, if they do not have statically
21401 compatible subtypes.
21402
21403 @node Aggregates in assignment statements
21404 @subsection Aggregates in assignment statements
21405
21406 @noindent
21407 In general, aggregate assignment requires the construction of a temporary,
21408 and a copy from the temporary to the target of the assignment. This is because
21409 it is not always possible to convert the assignment into a series of individual
21410 component assignments. For example, consider the simple case:
21411
21412 @smallexample @c ada
21413 A := (A(2), A(1));
21414 @end smallexample
21415
21416 @noindent
21417 This cannot be converted into:
21418
21419 @smallexample @c ada
21420 A(1) := A(2);
21421 A(2) := A(1);
21422 @end smallexample
21423
21424 @noindent
21425 So the aggregate has to be built first in a separate location, and then
21426 copied into the target. GNAT recognizes simple cases where this intermediate
21427 step is not required, and the assignments can be performed in place, directly
21428 into the target. The following sufficient criteria are applied:
21429
21430 @itemize @bullet
21431 @item
21432 The bounds of the aggregate are static, and the associations are static.
21433 @item
21434 The components of the aggregate are static constants, names of
21435 simple variables that are not renamings, or expressions not involving
21436 indexed components whose operands obey these rules.
21437 @end itemize
21438
21439 @noindent
21440 If any of these conditions are violated, the aggregate will be built in
21441 a temporary (created either by the front-end or the code generator) and then
21442 that temporary will be copied onto the target.
21443
21444 @node The Size of Discriminated Records with Default Discriminants
21445 @section The Size of Discriminated Records with Default Discriminants
21446
21447 @noindent
21448 If a discriminated type @code{T} has discriminants with default values, it is
21449 possible to declare an object of this type without providing an explicit
21450 constraint:
21451
21452 @smallexample @c ada
21453 @group
21454 type Size is range 1..100;
21455
21456 type Rec (D : Size := 15) is record
21457 Name : String (1..D);
21458 end T;
21459
21460 Word : Rec;
21461 @end group
21462 @end smallexample
21463
21464 @noindent
21465 Such an object is said to be @emph{unconstrained}.
21466 The discriminant of the object
21467 can be modified by a full assignment to the object, as long as it preserves the
21468 relation between the value of the discriminant, and the value of the components
21469 that depend on it:
21470
21471 @smallexample @c ada
21472 @group
21473 Word := (3, "yes");
21474
21475 Word := (5, "maybe");
21476
21477 Word := (5, "no"); -- raises Constraint_Error
21478 @end group
21479 @end smallexample
21480
21481 @noindent
21482 In order to support this behavior efficiently, an unconstrained object is
21483 given the maximum size that any value of the type requires. In the case
21484 above, @code{Word} has storage for the discriminant and for
21485 a @code{String} of length 100.
21486 It is important to note that unconstrained objects do not require dynamic
21487 allocation. It would be an improper implementation to place on the heap those
21488 components whose size depends on discriminants. (This improper implementation
21489 was used by some Ada83 compilers, where the @code{Name} component above
21490 would have
21491 been stored as a pointer to a dynamic string). Following the principle that
21492 dynamic storage management should never be introduced implicitly,
21493 an Ada compiler should reserve the full size for an unconstrained declared
21494 object, and place it on the stack.
21495
21496 This maximum size approach
21497 has been a source of surprise to some users, who expect the default
21498 values of the discriminants to determine the size reserved for an
21499 unconstrained object: ``If the default is 15, why should the object occupy
21500 a larger size?''
21501 The answer, of course, is that the discriminant may be later modified,
21502 and its full range of values must be taken into account. This is why the
21503 declaration:
21504
21505 @smallexample
21506 @group
21507 type Rec (D : Positive := 15) is record
21508 Name : String (1..D);
21509 end record;
21510
21511 Too_Large : Rec;
21512 @end group
21513 @end smallexample
21514
21515 @noindent
21516 is flagged by the compiler with a warning:
21517 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
21518 because the required size includes @code{Positive'Last}
21519 bytes. As the first example indicates, the proper approach is to declare an
21520 index type of ``reasonable'' range so that unconstrained objects are not too
21521 large.
21522
21523 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
21524 created in the heap by means of an allocator, then it is @emph{not}
21525 unconstrained:
21526 it is constrained by the default values of the discriminants, and those values
21527 cannot be modified by full assignment. This is because in the presence of
21528 aliasing all views of the object (which may be manipulated by different tasks,
21529 say) must be consistent, so it is imperative that the object, once created,
21530 remain invariant.
21531
21532 @node Strict Conformance to the Ada Reference Manual
21533 @section Strict Conformance to the Ada Reference Manual
21534
21535 @noindent
21536 The dynamic semantics defined by the Ada Reference Manual impose a set of
21537 run-time checks to be generated. By default, the GNAT compiler will insert many
21538 run-time checks into the compiled code, including most of those required by the
21539 Ada Reference Manual. However, there are three checks that are not enabled
21540 in the default mode for efficiency reasons: arithmetic overflow checking for
21541 integer operations (including division by zero), checks for access before
21542 elaboration on subprogram calls, and stack overflow checking (most operating
21543 systems do not perform this check by default).
21544
21545 Strict conformance to the Ada Reference Manual can be achieved by adding
21546 three compiler options for overflow checking for integer operations
21547 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
21548 calls and generic instantiations (@option{-gnatE}), and stack overflow
21549 checking (@option{-fstack-check}).
21550
21551 Note that the result of a floating point arithmetic operation in overflow and
21552 invalid situations, when the @code{Machine_Overflows} attribute of the result
21553 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
21554 case for machines compliant with the IEEE floating-point standard, but on
21555 machines that are not fully compliant with this standard, such as Alpha, the
21556 @option{-mieee} compiler flag must be used for achieving IEEE confirming
21557 behavior (although at the cost of a significant performance penalty), so
21558 infinite and NaN values are properly generated.
21559
21560
21561 @node Implementation of Ada 2012 Features
21562 @chapter Implementation of Ada 2012 Features
21563 @cindex Ada 2012 implementation status
21564
21565 This chapter contains a complete list of Ada 2012 features that have been
21566 implemented as of GNAT version 6.4. Generally, these features are only
21567 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
21568 @cindex @option{-gnat12} option
21569 or if the configuration pragma @code{Ada_2012} is used.
21570 @cindex pragma @code{Ada_2012}
21571 @cindex configuration pragma @code{Ada_2012}
21572 @cindex @code{Ada_2012} configuration pragma
21573 However, new pragmas, attributes, and restrictions are
21574 unconditionally available, since the Ada 95 standard allows the addition of
21575 new pragmas, attributes, and restrictions (there are exceptions, which are
21576 documented in the individual descriptions), and also certain packages
21577 were made available in earlier versions of Ada.
21578
21579 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
21580 This date shows the implementation date of the feature. Any wavefront
21581 subsequent to this date will contain the indicated feature, as will any
21582 subsequent releases. A date of 0000-00-00 means that GNAT has always
21583 implemented the feature, or implemented it as soon as it appeared as a
21584 binding interpretation.
21585
21586 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
21587 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
21588 The features are ordered based on the relevant sections of the Ada
21589 Reference Manual (``RM''). When a given AI relates to multiple points
21590 in the RM, the earliest is used.
21591
21592 A complete description of the AIs may be found in
21593 @url{www.ada-auth.org/ai05-summary.html}.
21594
21595 @itemize @bullet
21596
21597 @item
21598 @emph{AI-0176 Quantified expressions (2010-09-29)}
21599 @cindex AI-0176 (Ada 2012 feature)
21600
21601 @noindent
21602 Both universally and existentially quantified expressions are implemented.
21603 They use the new syntax for iterators proposed in AI05-139-2, as well as
21604 the standard Ada loop syntax.
21605
21606 @noindent
21607 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
21608
21609 @item
21610 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
21611 @cindex AI-0079 (Ada 2012 feature)
21612
21613 @noindent
21614 Wide characters in the unicode category @i{other_format} are now allowed in
21615 source programs between tokens, but not within a token such as an identifier.
21616
21617 @noindent
21618 RM References: 2.01 (4/2) 2.02 (7)
21619
21620 @item
21621 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
21622 @cindex AI-0091 (Ada 2012 feature)
21623
21624 @noindent
21625 Wide characters in the unicode category @i{other_format} are not permitted
21626 within an identifier, since this can be a security problem. The error
21627 message for this case has been improved to be more specific, but GNAT has
21628 never allowed such characters to appear in identifiers.
21629
21630 @noindent
21631 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)
21632
21633 @item
21634 @emph{AI-0100 Placement of pragmas (2010-07-01)}
21635 @cindex AI-0100 (Ada 2012 feature)
21636
21637 @noindent
21638 This AI is an earlier version of AI-163. It simplifies the rules
21639 for legal placement of pragmas. In the case of lists that allow pragmas, if
21640 the list may have no elements, then the list may consist solely of pragmas.
21641
21642 @noindent
21643 RM References: 2.08 (7)
21644
21645 @item
21646 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
21647 @cindex AI-0163 (Ada 2012 feature)
21648
21649 @noindent
21650 A statement sequence may be composed entirely of pragmas. It is no longer
21651 necessary to add a dummy @code{null} statement to make the sequence legal.
21652
21653 @noindent
21654 RM References: 2.08 (7) 2.08 (16)
21655
21656
21657 @item
21658 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
21659 @cindex AI-0080 (Ada 2012 feature)
21660
21661 @noindent
21662 This is an editorial change only, described as non-testable in the AI.
21663
21664 @noindent
21665 RM References: 3.01 (7)
21666
21667
21668 @item
21669 @emph{AI-0183 Aspect specifications (2010-08-16)}
21670 @cindex AI-0183 (Ada 2012 feature)
21671
21672 @noindent
21673 Aspect specifications have been fully implemented except for pre and post-
21674 conditions, and type invariants, which have their own separate AI's. All
21675 forms of declarations listed in the AI are supported. The following is a
21676 list of the aspects supported (with GNAT implementation aspects marked)
21677
21678 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
21679 @item @code{Ada_2005} @tab -- GNAT
21680 @item @code{Ada_2012} @tab -- GNAT
21681 @item @code{Address} @tab
21682 @item @code{Alignment} @tab
21683 @item @code{Atomic} @tab
21684 @item @code{Atomic_Components} @tab
21685 @item @code{Bit_Order} @tab
21686 @item @code{Component_Size} @tab
21687 @item @code{Contract_Cases} @tab -- GNAT
21688 @item @code{Discard_Names} @tab
21689 @item @code{External_Tag} @tab
21690 @item @code{Favor_Top_Level} @tab -- GNAT
21691 @item @code{Inline} @tab
21692 @item @code{Inline_Always} @tab -- GNAT
21693 @item @code{Invariant} @tab -- GNAT
21694 @item @code{Machine_Radix} @tab
21695 @item @code{No_Return} @tab
21696 @item @code{Object_Size} @tab -- GNAT
21697 @item @code{Pack} @tab
21698 @item @code{Persistent_BSS} @tab -- GNAT
21699 @item @code{Post} @tab
21700 @item @code{Pre} @tab
21701 @item @code{Predicate} @tab
21702 @item @code{Preelaborable_Initialization} @tab
21703 @item @code{Pure_Function} @tab -- GNAT
21704 @item @code{Remote_Access_Type} @tab -- GNAT
21705 @item @code{Shared} @tab -- GNAT
21706 @item @code{Size} @tab
21707 @item @code{Storage_Pool} @tab
21708 @item @code{Storage_Size} @tab
21709 @item @code{Stream_Size} @tab
21710 @item @code{Suppress} @tab
21711 @item @code{Suppress_Debug_Info} @tab -- GNAT
21712 @item @code{Test_Case} @tab -- GNAT
21713 @item @code{Thread_Local_Storage} @tab -- GNAT
21714 @item @code{Type_Invariant} @tab
21715 @item @code{Unchecked_Union} @tab
21716 @item @code{Universal_Aliasing} @tab -- GNAT
21717 @item @code{Unmodified} @tab -- GNAT
21718 @item @code{Unreferenced} @tab -- GNAT
21719 @item @code{Unreferenced_Objects} @tab -- GNAT
21720 @item @code{Unsuppress} @tab
21721 @item @code{Value_Size} @tab -- GNAT
21722 @item @code{Volatile} @tab
21723 @item @code{Volatile_Components}
21724 @item @code{Warnings} @tab -- GNAT
21725 @end multitable
21726
21727 @noindent
21728 Note that for aspects with an expression, e.g. @code{Size}, the expression is
21729 treated like a default expression (visibility is analyzed at the point of
21730 occurrence of the aspect, but evaluation of the expression occurs at the
21731 freeze point of the entity involved).
21732
21733 @noindent
21734 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
21735 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
21736 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
21737 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
21738 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
21739 13.03.01 (0)
21740
21741
21742 @item
21743 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
21744 @cindex AI-0128 (Ada 2012 feature)
21745
21746 @noindent
21747 If an equality operator ("=") is declared for a type, then the implicitly
21748 declared inequality operator ("/=") is a primitive operation of the type.
21749 This is the only reasonable interpretation, and is the one always implemented
21750 by GNAT, but the RM was not entirely clear in making this point.
21751
21752 @noindent
21753 RM References: 3.02.03 (6) 6.06 (6)
21754
21755 @item
21756 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
21757 @cindex AI-0003 (Ada 2012 feature)
21758
21759 @noindent
21760 In Ada 2012, a qualified expression is considered to be syntactically a name,
21761 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
21762 useful in disambiguating some cases of overloading.
21763
21764 @noindent
21765 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
21766 5.04 (7)
21767
21768 @item
21769 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
21770 @cindex AI-0120 (Ada 2012 feature)
21771
21772 @noindent
21773 This is an RM editorial change only. The section that lists objects that are
21774 constant failed to include the current instance of a protected object
21775 within a protected function. This has always been treated as a constant
21776 in GNAT.
21777
21778 @noindent
21779 RM References: 3.03 (21)
21780
21781 @item
21782 @emph{AI-0008 General access to constrained objects (0000-00-00)}
21783 @cindex AI-0008 (Ada 2012 feature)
21784
21785 @noindent
21786 The wording in the RM implied that if you have a general access to a
21787 constrained object, it could be used to modify the discriminants. This was
21788 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
21789 has always done so in this situation.
21790
21791 @noindent
21792 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
21793
21794
21795 @item
21796 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
21797 @cindex AI-0093 (Ada 2012 feature)
21798
21799 @noindent
21800 This is an editorial change only, to make more widespread use of the Ada 2012
21801 ``immutably limited''.
21802
21803 @noindent
21804 RM References: 3.03 (23.4/3)
21805
21806
21807
21808 @item
21809 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
21810 @cindex AI-0096 (Ada 2012 feature)
21811
21812 @noindent
21813 In general it is illegal for a type derived from a formal limited type to be
21814 nonlimited. This AI makes an exception to this rule: derivation is legal
21815 if it appears in the private part of the generic, and the formal type is not
21816 tagged. If the type is tagged, the legality check must be applied to the
21817 private part of the package.
21818
21819 @noindent
21820 RM References: 3.04 (5.1/2) 6.02 (7)
21821
21822
21823 @item
21824 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
21825 @cindex AI-0181 (Ada 2012 feature)
21826
21827 @noindent
21828 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
21829 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
21830 @code{Image} and @code{Value} attributes for the character types. Strictly
21831 speaking this is an inconsistency with Ada 95, but in practice the use of
21832 these attributes is so obscure that it will not cause problems.
21833
21834 @noindent
21835 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
21836
21837
21838 @item
21839 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
21840 @cindex AI-0182 (Ada 2012 feature)
21841
21842 @noindent
21843 This AI allows @code{Character'Value} to accept the string @code{'?'} where
21844 @code{?} is any character including non-graphic control characters. GNAT has
21845 always accepted such strings. It also allows strings such as
21846 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
21847 permission and raises @code{Constraint_Error}, as is certainly still
21848 permitted.
21849
21850 @noindent
21851 RM References: 3.05 (56/2)
21852
21853
21854 @item
21855 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
21856 @cindex AI-0214 (Ada 2012 feature)
21857
21858 @noindent
21859 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
21860 to have default expressions by allowing them when the type is limited. It
21861 is often useful to define a default value for a discriminant even though
21862 it can't be changed by assignment.
21863
21864 @noindent
21865 RM References: 3.07 (9.1/2) 3.07.02 (3)
21866
21867
21868 @item
21869 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
21870 @cindex AI-0102 (Ada 2012 feature)
21871
21872 @noindent
21873 It is illegal to assign an anonymous access constant to an anonymous access
21874 variable. The RM did not have a clear rule to prevent this, but GNAT has
21875 always generated an error for this usage.
21876
21877 @noindent
21878 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
21879
21880
21881 @item
21882 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
21883 @cindex AI-0158 (Ada 2012 feature)
21884
21885 @noindent
21886 This AI extends the syntax of membership tests to simplify complex conditions
21887 that can be expressed as membership in a subset of values of any type. It
21888 introduces syntax for a list of expressions that may be used in loop contexts
21889 as well.
21890
21891 @noindent
21892 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
21893
21894
21895 @item
21896 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
21897 @cindex AI-0173 (Ada 2012 feature)
21898
21899 @noindent
21900 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
21901 with the tag of an abstract type, and @code{False} otherwise.
21902
21903 @noindent
21904 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
21905
21906
21907
21908 @item
21909 @emph{AI-0076 function with controlling result (0000-00-00)}
21910 @cindex AI-0076 (Ada 2012 feature)
21911
21912 @noindent
21913 This is an editorial change only. The RM defines calls with controlling
21914 results, but uses the term ``function with controlling result'' without an
21915 explicit definition.
21916
21917 @noindent
21918 RM References: 3.09.02 (2/2)
21919
21920
21921 @item
21922 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
21923 @cindex AI-0126 (Ada 2012 feature)
21924
21925 @noindent
21926 This AI clarifies dispatching rules, and simply confirms that dispatching
21927 executes the operation of the parent type when there is no explicitly or
21928 implicitly declared operation for the descendant type. This has always been
21929 the case in all versions of GNAT.
21930
21931 @noindent
21932 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
21933
21934
21935 @item
21936 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
21937 @cindex AI-0097 (Ada 2012 feature)
21938
21939 @noindent
21940 The RM as written implied that in some cases it was possible to create an
21941 object of an abstract type, by having an abstract extension inherit a non-
21942 abstract constructor from its parent type. This mistake has been corrected
21943 in GNAT and in the RM, and this construct is now illegal.
21944
21945 @noindent
21946 RM References: 3.09.03 (4/2)
21947
21948
21949 @item
21950 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
21951 @cindex AI-0203 (Ada 2012 feature)
21952
21953 @noindent
21954 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
21955 permitted such usage.
21956
21957 @noindent
21958 RM References: 3.09.03 (8/3)
21959
21960
21961 @item
21962 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
21963 @cindex AI-0198 (Ada 2012 feature)
21964
21965 @noindent
21966 This AI resolves a conflict between two rules involving inherited abstract
21967 operations and predefined operators. If a derived numeric type inherits
21968 an abstract operator, it overrides the predefined one. This interpretation
21969 was always the one implemented in GNAT.
21970
21971 @noindent
21972 RM References: 3.09.03 (4/3)
21973
21974 @item
21975 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
21976 @cindex AI-0073 (Ada 2012 feature)
21977
21978 @noindent
21979 This AI covers a number of issues regarding returning abstract types. In
21980 particular generic functions cannot have abstract result types or access
21981 result types designated an abstract type. There are some other cases which
21982 are detailed in the AI. Note that this binding interpretation has not been
21983 retrofitted to operate before Ada 2012 mode, since it caused a significant
21984 number of regressions.
21985
21986 @noindent
21987 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
21988
21989
21990 @item
21991 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
21992 @cindex AI-0070 (Ada 2012 feature)
21993
21994 @noindent
21995 This is an editorial change only, there are no testable consequences short of
21996 checking for the absence of generated code for an interface declaration.
21997
21998 @noindent
21999 RM References: 3.09.04 (18/2)
22000
22001
22002 @item
22003 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
22004 @cindex AI-0208 (Ada 2012 feature)
22005
22006 @noindent
22007 The wording in the Ada 2005 RM concerning characteristics of incomplete views
22008 was incorrect and implied that some programs intended to be legal were now
22009 illegal. GNAT had never considered such programs illegal, so it has always
22010 implemented the intent of this AI.
22011
22012 @noindent
22013 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
22014
22015
22016 @item
22017 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
22018 @cindex AI-0162 (Ada 2012 feature)
22019
22020 @noindent
22021 Incomplete types are made more useful by allowing them to be completed by
22022 private types and private extensions.
22023
22024 @noindent
22025 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
22026
22027
22028
22029 @item
22030 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
22031 @cindex AI-0098 (Ada 2012 feature)
22032
22033 @noindent
22034 An unintentional omission in the RM implied some inconsistent restrictions on
22035 the use of anonymous access to subprogram values. These restrictions were not
22036 intentional, and have never been enforced by GNAT.
22037
22038 @noindent
22039 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
22040
22041
22042 @item
22043 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
22044 @cindex AI-0199 (Ada 2012 feature)
22045
22046 @noindent
22047 A choice list in a record aggregate can include several components of
22048 (distinct) anonymous access types as long as they have matching designated
22049 subtypes.
22050
22051 @noindent
22052 RM References: 4.03.01 (16)
22053
22054
22055 @item
22056 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
22057 @cindex AI-0220 (Ada 2012 feature)
22058
22059 @noindent
22060 This AI addresses a wording problem in the RM that appears to permit some
22061 complex cases of aggregates with non-static discriminants. GNAT has always
22062 implemented the intended semantics.
22063
22064 @noindent
22065 RM References: 4.03.01 (17)
22066
22067 @item
22068 @emph{AI-0147 Conditional expressions (2009-03-29)}
22069 @cindex AI-0147 (Ada 2012 feature)
22070
22071 @noindent
22072 Conditional expressions are permitted. The form of such an expression is:
22073
22074 @smallexample
22075 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
22076 @end smallexample
22077
22078 The parentheses can be omitted in contexts where parentheses are present
22079 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
22080 clause is omitted, @b{else True} is assumed;
22081 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
22082 @emph{(A implies B)} in standard logic.
22083
22084 @noindent
22085 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
22086 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
22087
22088
22089 @item
22090 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
22091 @cindex AI-0037 (Ada 2012 feature)
22092
22093 @noindent
22094 This AI confirms that an association of the form @code{Indx => <>} in an
22095 array aggregate must raise @code{Constraint_Error} if @code{Indx}
22096 is out of range. The RM specified a range check on other associations, but
22097 not when the value of the association was defaulted. GNAT has always inserted
22098 a constraint check on the index value.
22099
22100 @noindent
22101 RM References: 4.03.03 (29)
22102
22103
22104 @item
22105 @emph{AI-0123 Composability of equality (2010-04-13)}
22106 @cindex AI-0123 (Ada 2012 feature)
22107
22108 @noindent
22109 Equality of untagged record composes, so that the predefined equality for a
22110 composite type that includes a component of some untagged record type
22111 @code{R} uses the equality operation of @code{R} (which may be user-defined
22112 or predefined). This makes the behavior of untagged records identical to that
22113 of tagged types in this respect.
22114
22115 This change is an incompatibility with previous versions of Ada, but it
22116 corrects a non-uniformity that was often a source of confusion. Analysis of
22117 a large number of industrial programs indicates that in those rare cases
22118 where a composite type had an untagged record component with a user-defined
22119 equality, either there was no use of the composite equality, or else the code
22120 expected the same composability as for tagged types, and thus had a bug that
22121 would be fixed by this change.
22122
22123 @noindent
22124 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
22125 8.05.04 (8)
22126
22127
22128 @item
22129 @emph{AI-0088 The value of exponentiation (0000-00-00)}
22130 @cindex AI-0088 (Ada 2012 feature)
22131
22132 @noindent
22133 This AI clarifies the equivalence rule given for the dynamic semantics of
22134 exponentiation: the value of the operation can be obtained by repeated
22135 multiplication, but the operation can be implemented otherwise (for example
22136 using the familiar divide-by-two-and-square algorithm, even if this is less
22137 accurate), and does not imply repeated reads of a volatile base.
22138
22139 @noindent
22140 RM References: 4.05.06 (11)
22141
22142 @item
22143 @emph{AI-0188 Case expressions (2010-01-09)}
22144 @cindex AI-0188 (Ada 2012 feature)
22145
22146 @noindent
22147 Case expressions are permitted. This allows use of constructs such as:
22148 @smallexample
22149 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
22150 @end smallexample
22151
22152 @noindent
22153 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
22154
22155 @item
22156 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
22157 @cindex AI-0104 (Ada 2012 feature)
22158
22159 @noindent
22160 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
22161 @code{Constraint_Error} because the default value of the allocated object is
22162 @b{null}. This useless construct is illegal in Ada 2012.
22163
22164 @noindent
22165 RM References: 4.08 (2)
22166
22167 @item
22168 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
22169 @cindex AI-0157 (Ada 2012 feature)
22170
22171 @noindent
22172 Allocation and Deallocation from an empty storage pool (i.e. allocation or
22173 deallocation of a pointer for which a static storage size clause of zero
22174 has been given) is now illegal and is detected as such. GNAT
22175 previously gave a warning but not an error.
22176
22177 @noindent
22178 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
22179
22180 @item
22181 @emph{AI-0179 Statement not required after label (2010-04-10)}
22182 @cindex AI-0179 (Ada 2012 feature)
22183
22184 @noindent
22185 It is not necessary to have a statement following a label, so a label
22186 can appear at the end of a statement sequence without the need for putting a
22187 null statement afterwards, but it is not allowable to have only labels and
22188 no real statements in a statement sequence.
22189
22190 @noindent
22191 RM References: 5.01 (2)
22192
22193
22194 @item
22195 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
22196 @cindex AI-139-2 (Ada 2012 feature)
22197
22198 @noindent
22199 The new syntax for iterating over arrays and containers is now implemented.
22200 Iteration over containers is for now limited to read-only iterators. Only
22201 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
22202
22203 @noindent
22204 RM References: 5.05
22205
22206 @item
22207 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
22208 @cindex AI-0134 (Ada 2012 feature)
22209
22210 @noindent
22211 For full conformance, the profiles of anonymous-access-to-subprogram
22212 parameters must match. GNAT has always enforced this rule.
22213
22214 @noindent
22215 RM References: 6.03.01 (18)
22216
22217 @item
22218 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
22219 @cindex AI-0207 (Ada 2012 feature)
22220
22221 @noindent
22222 This AI confirms that access_to_constant indication must match for mode
22223 conformance. This was implemented in GNAT when the qualifier was originally
22224 introduced in Ada 2005.
22225
22226 @noindent
22227 RM References: 6.03.01 (16/2)
22228
22229
22230 @item
22231 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
22232 @cindex AI-0046 (Ada 2012 feature)
22233
22234 @noindent
22235 For full conformance, in the case of access parameters, the null exclusion
22236 must match (either both or neither must have @code{@b{not null}}).
22237
22238 @noindent
22239 RM References: 6.03.02 (18)
22240
22241
22242 @item
22243 @emph{AI-0118 The association of parameter associations (0000-00-00)}
22244 @cindex AI-0118 (Ada 2012 feature)
22245
22246 @noindent
22247 This AI clarifies the rules for named associations in subprogram calls and
22248 generic instantiations. The rules have been in place since Ada 83.
22249
22250 @noindent
22251 RM References: 6.04.01 (2) 12.03 (9)
22252
22253
22254 @item
22255 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
22256 @cindex AI-0196 (Ada 2012 feature)
22257
22258 @noindent
22259 Null exclusion checks are not made for @code{@b{out}} parameters when
22260 evaluating the actual parameters. GNAT has never generated these checks.
22261
22262 @noindent
22263 RM References: 6.04.01 (13)
22264
22265 @item
22266 @emph{AI-0015 Constant return objects (0000-00-00)}
22267 @cindex AI-0015 (Ada 2012 feature)
22268
22269 @noindent
22270 The return object declared in an @i{extended_return_statement} may be
22271 declared constant. This was always intended, and GNAT has always allowed it.
22272
22273 @noindent
22274 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
22275 6.05 (5.7/2)
22276
22277
22278 @item
22279 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
22280 @cindex AI-0032 (Ada 2012 feature)
22281
22282 @noindent
22283 If a function returns a class-wide type, the object of an extended return
22284 statement can be declared with a specific type that is covered by the class-
22285 wide type. This has been implemented in GNAT since the introduction of
22286 extended returns. Note AI-0103 complements this AI by imposing matching
22287 rules for constrained return types.
22288
22289 @noindent
22290 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
22291 6.05 (8/2)
22292
22293 @item
22294 @emph{AI-0103 Static matching for extended return (2010-07-23)}
22295 @cindex AI-0103 (Ada 2012 feature)
22296
22297 @noindent
22298 If the return subtype of a function is an elementary type or a constrained
22299 type, the subtype indication in an extended return statement must match
22300 statically this return subtype.
22301
22302 @noindent
22303 RM References: 6.05 (5.2/2)
22304
22305
22306 @item
22307 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
22308 @cindex AI-0058 (Ada 2012 feature)
22309
22310 @noindent
22311 The RM had some incorrect wording implying wrong treatment of abnormal
22312 completion in an extended return. GNAT has always implemented the intended
22313 correct semantics as described by this AI.
22314
22315 @noindent
22316 RM References: 6.05 (22/2)
22317
22318
22319 @item
22320 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
22321 @cindex AI-0050 (Ada 2012 feature)
22322
22323 @noindent
22324 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
22325 not take advantage of these incorrect permissions in any case.
22326
22327 @noindent
22328 RM References: 6.05 (24/2)
22329
22330
22331 @item
22332 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
22333 @cindex AI-0125 (Ada 2012 feature)
22334
22335 @noindent
22336 In Ada 2012, the declaration of a primitive operation of a type extension
22337 or private extension can also override an inherited primitive that is not
22338 visible at the point of this declaration.
22339
22340 @noindent
22341 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
22342
22343 @item
22344 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
22345 @cindex AI-0062 (Ada 2012 feature)
22346
22347 @noindent
22348 A full constant may have a null exclusion even if its associated deferred
22349 constant does not. GNAT has always allowed this.
22350
22351 @noindent
22352 RM References: 7.04 (6/2) 7.04 (7.1/2)
22353
22354
22355 @item
22356 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
22357 @cindex AI-0178 (Ada 2012 feature)
22358
22359 @noindent
22360 This AI clarifies the role of incomplete views and plugs an omission in the
22361 RM. GNAT always correctly restricted the use of incomplete views and types.
22362
22363 @noindent
22364 RM References: 7.05 (3/2) 7.05 (6/2)
22365
22366 @item
22367 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
22368 @cindex AI-0087 (Ada 2012 feature)
22369
22370 @noindent
22371 The actual for a formal nonlimited derived type cannot be limited. In
22372 particular, a formal derived type that extends a limited interface but which
22373 is not explicitly limited cannot be instantiated with a limited type.
22374
22375 @noindent
22376 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
22377
22378 @item
22379 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
22380 @cindex AI-0099 (Ada 2012 feature)
22381
22382 @noindent
22383 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
22384 and therefore depends on the run-time characteristics of an object (i.e. its
22385 tag) and not on its nominal type. As the AI indicates: ``we do not expect
22386 this to affect any implementation''.
22387
22388 @noindent
22389 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
22390
22391
22392
22393 @item
22394 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
22395 @cindex AI-0064 (Ada 2012 feature)
22396
22397 @noindent
22398 This is an editorial change only. The intended behavior is already checked
22399 by an existing ACATS test, which GNAT has always executed correctly.
22400
22401 @noindent
22402 RM References: 7.06.01 (17.1/1)
22403
22404 @item
22405 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
22406 @cindex AI-0026 (Ada 2012 feature)
22407
22408 @noindent
22409 Record representation clauses concerning Unchecked_Union types cannot mention
22410 the discriminant of the type. The type of a component declared in the variant
22411 part of an Unchecked_Union cannot be controlled, have controlled components,
22412 nor have protected or task parts. If an Unchecked_Union type is declared
22413 within the body of a generic unit or its descendants, then the type of a
22414 component declared in the variant part cannot be a formal private type or a
22415 formal private extension declared within the same generic unit.
22416
22417 @noindent
22418 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
22419
22420
22421 @item
22422 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
22423 @cindex AI-0205 (Ada 2012 feature)
22424
22425 @noindent
22426 This AI corrects a simple omission in the RM. Return objects have always
22427 been visible within an extended return statement.
22428
22429 @noindent
22430 RM References: 8.03 (17)
22431
22432
22433 @item
22434 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
22435 @cindex AI-0042 (Ada 2012 feature)
22436
22437 @noindent
22438 This AI fixes a wording gap in the RM. An operation of a synchronized
22439 interface can be implemented by a protected or task entry, but the abstract
22440 operation is not being overridden in the usual sense, and it must be stated
22441 separately that this implementation is legal. This has always been the case
22442 in GNAT.
22443
22444 @noindent
22445 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
22446
22447 @item
22448 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
22449 @cindex AI-0030 (Ada 2012 feature)
22450
22451 @noindent
22452 Requeue is permitted to a protected, synchronized or task interface primitive
22453 providing it is known that the overriding operation is an entry. Otherwise
22454 the requeue statement has the same effect as a procedure call. Use of pragma
22455 @code{Implemented} provides a way to impose a static requirement on the
22456 overriding operation by adhering to one of the implementation kinds: entry,
22457 protected procedure or any of the above.
22458
22459 @noindent
22460 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
22461 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
22462
22463
22464 @item
22465 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
22466 @cindex AI-0201 (Ada 2012 feature)
22467
22468 @noindent
22469 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
22470 attribute, then individual components may not be addressable by independent
22471 tasks. However, if the representation clause has no effect (is confirming),
22472 then independence is not compromised. Furthermore, in GNAT, specification of
22473 other appropriately addressable component sizes (e.g. 16 for 8-bit
22474 characters) also preserves independence. GNAT now gives very clear warnings
22475 both for the declaration of such a type, and for any assignment to its components.
22476
22477 @noindent
22478 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
22479
22480 @item
22481 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
22482 @cindex AI-0009 (Ada 2012 feature)
22483
22484 @noindent
22485 This AI introduces the new pragmas @code{Independent} and
22486 @code{Independent_Components},
22487 which control guaranteeing independence of access to objects and components.
22488 The AI also requires independence not unaffected by confirming rep clauses.
22489
22490 @noindent
22491 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
22492 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
22493
22494
22495 @item
22496 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
22497 @cindex AI-0072 (Ada 2012 feature)
22498
22499 @noindent
22500 This AI clarifies that task signalling for reading @code{'Terminated} only
22501 occurs if the result is True. GNAT semantics has always been consistent with
22502 this notion of task signalling.
22503
22504 @noindent
22505 RM References: 9.10 (6.1/1)
22506
22507 @item
22508 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
22509 @cindex AI-0108 (Ada 2012 feature)
22510
22511 @noindent
22512 This AI confirms that an incomplete type from a limited view does not have
22513 discriminants. This has always been the case in GNAT.
22514
22515 @noindent
22516 RM References: 10.01.01 (12.3/2)
22517
22518 @item
22519 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
22520 @cindex AI-0129 (Ada 2012 feature)
22521
22522 @noindent
22523 This AI clarifies the description of limited views: a limited view of a
22524 package includes only one view of a type that has an incomplete declaration
22525 and a full declaration (there is no possible ambiguity in a client package).
22526 This AI also fixes an omission: a nested package in the private part has no
22527 limited view. GNAT always implemented this correctly.
22528
22529 @noindent
22530 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
22531
22532
22533
22534 @item
22535 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
22536 @cindex AI-0077 (Ada 2012 feature)
22537
22538 @noindent
22539 This AI clarifies that a declaration does not include a context clause,
22540 and confirms that it is illegal to have a context in which both a limited
22541 and a nonlimited view of a package are accessible. Such double visibility
22542 was always rejected by GNAT.
22543
22544 @noindent
22545 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
22546
22547 @item
22548 @emph{AI-0122 Private with and children of generics (0000-00-00)}
22549 @cindex AI-0122 (Ada 2012 feature)
22550
22551 @noindent
22552 This AI clarifies the visibility of private children of generic units within
22553 instantiations of a parent. GNAT has always handled this correctly.
22554
22555 @noindent
22556 RM References: 10.01.02 (12/2)
22557
22558
22559
22560 @item
22561 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
22562 @cindex AI-0040 (Ada 2012 feature)
22563
22564 @noindent
22565 This AI confirms that a limited with clause in a child unit cannot name
22566 an ancestor of the unit. This has always been checked in GNAT.
22567
22568 @noindent
22569 RM References: 10.01.02 (20/2)
22570
22571 @item
22572 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
22573 @cindex AI-0132 (Ada 2012 feature)
22574
22575 @noindent
22576 This AI fills a gap in the description of library unit pragmas. The pragma
22577 clearly must apply to a library unit, even if it does not carry the name
22578 of the enclosing unit. GNAT has always enforced the required check.
22579
22580 @noindent
22581 RM References: 10.01.05 (7)
22582
22583
22584 @item
22585 @emph{AI-0034 Categorization of limited views (0000-00-00)}
22586 @cindex AI-0034 (Ada 2012 feature)
22587
22588 @noindent
22589 The RM makes certain limited with clauses illegal because of categorization
22590 considerations, when the corresponding normal with would be legal. This is
22591 not intended, and GNAT has always implemented the recommended behavior.
22592
22593 @noindent
22594 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
22595
22596
22597 @item
22598 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
22599 @cindex AI-0035 (Ada 2012 feature)
22600
22601 @noindent
22602 This AI remedies some inconsistencies in the legality rules for Pure units.
22603 Derived access types are legal in a pure unit (on the assumption that the
22604 rule for a zero storage pool size has been enforced on the ancestor type).
22605 The rules are enforced in generic instances and in subunits. GNAT has always
22606 implemented the recommended behavior.
22607
22608 @noindent
22609 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)
22610
22611
22612 @item
22613 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
22614 @cindex AI-0219 (Ada 2012 feature)
22615
22616 @noindent
22617 This AI refines the rules for the cases with limited parameters which do not
22618 allow the implementations to omit ``redundant''. GNAT now properly conforms
22619 to the requirements of this binding interpretation.
22620
22621 @noindent
22622 RM References: 10.02.01 (18/2)
22623
22624 @item
22625 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
22626 @cindex AI-0043 (Ada 2012 feature)
22627
22628 @noindent
22629 This AI covers various omissions in the RM regarding the raising of
22630 exceptions. GNAT has always implemented the intended semantics.
22631
22632 @noindent
22633 RM References: 11.04.01 (10.1/2) 11 (2)
22634
22635
22636 @item
22637 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
22638 @cindex AI-0200 (Ada 2012 feature)
22639
22640 @noindent
22641 This AI plugs a gap in the RM which appeared to allow some obviously intended
22642 illegal instantiations. GNAT has never allowed these instantiations.
22643
22644 @noindent
22645 RM References: 12.07 (16)
22646
22647
22648 @item
22649 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
22650 @cindex AI-0112 (Ada 2012 feature)
22651
22652 @noindent
22653 This AI concerns giving names to various representation aspects, but the
22654 practical effect is simply to make the use of duplicate
22655 @code{Atomic}[@code{_Components}],
22656 @code{Volatile}[@code{_Components}] and
22657 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
22658 now performs this required check.
22659
22660 @noindent
22661 RM References: 13.01 (8)
22662
22663 @item
22664 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
22665 @cindex AI-0106 (Ada 2012 feature)
22666
22667 @noindent
22668 The RM appeared to allow representation pragmas on generic formal parameters,
22669 but this was not intended, and GNAT has never permitted this usage.
22670
22671 @noindent
22672 RM References: 13.01 (9.1/1)
22673
22674
22675 @item
22676 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
22677 @cindex AI-0012 (Ada 2012 feature)
22678
22679 @noindent
22680 It is now illegal to give an inappropriate component size or a pragma
22681 @code{Pack} that attempts to change the component size in the case of atomic
22682 or aliased components. Previously GNAT ignored such an attempt with a
22683 warning.
22684
22685 @noindent
22686 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
22687
22688
22689 @item
22690 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
22691 @cindex AI-0039 (Ada 2012 feature)
22692
22693 @noindent
22694 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
22695 for stream attributes, but these were never useful and are now illegal. GNAT
22696 has always regarded such expressions as illegal.
22697
22698 @noindent
22699 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
22700
22701
22702 @item
22703 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
22704 @cindex AI-0095 (Ada 2012 feature)
22705
22706 @noindent
22707 The prefix of @code{'Address} cannot statically denote a subprogram with
22708 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
22709 @code{Program_Error} if the prefix denotes a subprogram with convention
22710 @code{Intrinsic}.
22711
22712 @noindent
22713 RM References: 13.03 (11/1)
22714
22715
22716 @item
22717 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
22718 @cindex AI-0116 (Ada 2012 feature)
22719
22720 @noindent
22721 This AI requires that the alignment of a class-wide object be no greater
22722 than the alignment of any type in the class. GNAT has always followed this
22723 recommendation.
22724
22725 @noindent
22726 RM References: 13.03 (29) 13.11 (16)
22727
22728
22729 @item
22730 @emph{AI-0146 Type invariants (2009-09-21)}
22731 @cindex AI-0146 (Ada 2012 feature)
22732
22733 @noindent
22734 Type invariants may be specified for private types using the aspect notation.
22735 Aspect @code{Type_Invariant} may be specified for any private type,
22736 @code{Type_Invariant'Class} can
22737 only be specified for tagged types, and is inherited by any descendent of the
22738 tagged types. The invariant is a boolean expression that is tested for being
22739 true in the following situations: conversions to the private type, object
22740 declarations for the private type that are default initialized, and
22741 [@b{in}] @b{out}
22742 parameters and returned result on return from any primitive operation for
22743 the type that is visible to a client.
22744 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
22745 @code{Invariant'Class} for @code{Type_Invariant'Class}.
22746
22747 @noindent
22748 RM References: 13.03.03 (00)
22749
22750 @item
22751 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
22752 @cindex AI-0078 (Ada 2012 feature)
22753
22754 @noindent
22755 In Ada 2012, compilers are required to support unchecked conversion where the
22756 target alignment is a multiple of the source alignment. GNAT always supported
22757 this case (and indeed all cases of differing alignments, doing copies where
22758 required if the alignment was reduced).
22759
22760 @noindent
22761 RM References: 13.09 (7)
22762
22763
22764 @item
22765 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
22766 @cindex AI-0195 (Ada 2012 feature)
22767
22768 @noindent
22769 The handling of invalid values is now designated to be implementation
22770 defined. This is a documentation change only, requiring Annex M in the GNAT
22771 Reference Manual to document this handling.
22772 In GNAT, checks for invalid values are made
22773 only when necessary to avoid erroneous behavior. Operations like assignments
22774 which cannot cause erroneous behavior ignore the possibility of invalid
22775 values and do not do a check. The date given above applies only to the
22776 documentation change, this behavior has always been implemented by GNAT.
22777
22778 @noindent
22779 RM References: 13.09.01 (10)
22780
22781 @item
22782 @emph{AI-0193 Alignment of allocators (2010-09-16)}
22783 @cindex AI-0193 (Ada 2012 feature)
22784
22785 @noindent
22786 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
22787 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
22788 of size.
22789
22790 @noindent
22791 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
22792 13.11.01 (2) 13.11.01 (3)
22793
22794
22795 @item
22796 @emph{AI-0177 Parameterized expressions (2010-07-10)}
22797 @cindex AI-0177 (Ada 2012 feature)
22798
22799 @noindent
22800 The new Ada 2012 notion of parameterized expressions is implemented. The form
22801 is:
22802 @smallexample
22803 @i{function specification} @b{is} (@i{expression})
22804 @end smallexample
22805
22806 @noindent
22807 This is exactly equivalent to the
22808 corresponding function body that returns the expression, but it can appear
22809 in a package spec. Note that the expression must be parenthesized.
22810
22811 @noindent
22812 RM References: 13.11.01 (3/2)
22813
22814 @item
22815 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
22816 @cindex AI-0033 (Ada 2012 feature)
22817
22818 @noindent
22819 Neither of these two pragmas may appear within a generic template, because
22820 the generic might be instantiated at other than the library level.
22821
22822 @noindent
22823 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
22824
22825
22826 @item
22827 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
22828 @cindex AI-0161 (Ada 2012 feature)
22829
22830 @noindent
22831 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
22832 of the default stream attributes for elementary types. If this restriction is
22833 in force, then it is necessary to provide explicit subprograms for any
22834 stream attributes used.
22835
22836 @noindent
22837 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
22838
22839 @item
22840 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
22841 @cindex AI-0194 (Ada 2012 feature)
22842
22843 @noindent
22844 The @code{Stream_Size} attribute returns the default number of bits in the
22845 stream representation of the given type.
22846 This value is not affected by the presence
22847 of stream subprogram attributes for the type. GNAT has always implemented
22848 this interpretation.
22849
22850 @noindent
22851 RM References: 13.13.02 (1.2/2)
22852
22853 @item
22854 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
22855 @cindex AI-0109 (Ada 2012 feature)
22856
22857 @noindent
22858 This AI is an editorial change only. It removes the need for a tag check
22859 that can never fail.
22860
22861 @noindent
22862 RM References: 13.13.02 (34/2)
22863
22864 @item
22865 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
22866 @cindex AI-0007 (Ada 2012 feature)
22867
22868 @noindent
22869 The RM as written appeared to limit the possibilities of declaring read
22870 attribute procedures for private scalar types. This limitation was not
22871 intended, and has never been enforced by GNAT.
22872
22873 @noindent
22874 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
22875
22876
22877 @item
22878 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
22879 @cindex AI-0065 (Ada 2012 feature)
22880
22881 @noindent
22882 This AI clarifies the fact that all remote access types support external
22883 streaming. This fixes an obvious oversight in the definition of the
22884 language, and GNAT always implemented the intended correct rules.
22885
22886 @noindent
22887 RM References: 13.13.02 (52/2)
22888
22889 @item
22890 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
22891 @cindex AI-0019 (Ada 2012 feature)
22892
22893 @noindent
22894 The RM suggests that primitive subprograms of a specific tagged type are
22895 frozen when the tagged type is frozen. This would be an incompatible change
22896 and is not intended. GNAT has never attempted this kind of freezing and its
22897 behavior is consistent with the recommendation of this AI.
22898
22899 @noindent
22900 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)
22901
22902 @item
22903 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
22904 @cindex AI-0017 (Ada 2012 feature)
22905
22906 @noindent
22907 So-called ``Taft-amendment types'' (i.e., types that are completed in package
22908 bodies) are not frozen by the occurrence of bodies in the
22909 enclosing declarative part. GNAT always implemented this properly.
22910
22911 @noindent
22912 RM References: 13.14 (3/1)
22913
22914
22915 @item
22916 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
22917 @cindex AI-0060 (Ada 2012 feature)
22918
22919 @noindent
22920 This AI extends the definition of remote access types to include access
22921 to limited, synchronized, protected or task class-wide interface types.
22922 GNAT already implemented this extension.
22923
22924 @noindent
22925 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
22926
22927 @item
22928 @emph{AI-0114 Classification of letters (0000-00-00)}
22929 @cindex AI-0114 (Ada 2012 feature)
22930
22931 @noindent
22932 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
22933 181 (@code{MICRO SIGN}), and
22934 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
22935 lower case letters by Unicode.
22936 However, they are not allowed in identifiers, and they
22937 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
22938 This behavior is consistent with that defined in Ada 95.
22939
22940 @noindent
22941 RM References: A.03.02 (59) A.04.06 (7)
22942
22943
22944 @item
22945 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
22946 @cindex AI-0185 (Ada 2012 feature)
22947
22948 @noindent
22949 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
22950 classification functions for @code{Wide_Character} and
22951 @code{Wide_Wide_Character}, as well as providing
22952 case folding routines for @code{Wide_[Wide_]Character} and
22953 @code{Wide_[Wide_]String}.
22954
22955 @noindent
22956 RM References: A.03.05 (0) A.03.06 (0)
22957
22958
22959 @item
22960 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
22961 @cindex AI-0031 (Ada 2012 feature)
22962
22963 @noindent
22964 A new version of @code{Find_Token} is added to all relevant string packages,
22965 with an extra parameter @code{From}. Instead of starting at the first
22966 character of the string, the search for a matching Token starts at the
22967 character indexed by the value of @code{From}.
22968 These procedures are available in all versions of Ada
22969 but if used in versions earlier than Ada 2012 they will generate a warning
22970 that an Ada 2012 subprogram is being used.
22971
22972 @noindent
22973 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
22974 A.04.05 (46)
22975
22976
22977 @item
22978 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
22979 @cindex AI-0056 (Ada 2012 feature)
22980
22981 @noindent
22982 The wording in the Ada 2005 RM implied an incompatible handling of the
22983 @code{Index} functions, resulting in raising an exception instead of
22984 returning zero in some situations.
22985 This was not intended and has been corrected.
22986 GNAT always returned zero, and is thus consistent with this AI.
22987
22988 @noindent
22989 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
22990
22991
22992 @item
22993 @emph{AI-0137 String encoding package (2010-03-25)}
22994 @cindex AI-0137 (Ada 2012 feature)
22995
22996 @noindent
22997 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
22998 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
22999 and @code{Wide_Wide_Strings} have been
23000 implemented. These packages (whose documentation can be found in the spec
23001 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
23002 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
23003 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
23004 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
23005 UTF-16), as well as conversions between the different UTF encodings. With
23006 the exception of @code{Wide_Wide_Strings}, these packages are available in
23007 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
23008 The @code{Wide_Wide_Strings package}
23009 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
23010 mode since it uses @code{Wide_Wide_Character}).
23011
23012 @noindent
23013 RM References: A.04.11
23014
23015 @item
23016 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
23017 @cindex AI-0038 (Ada 2012 feature)
23018
23019 @noindent
23020 These are minor errors in the description on three points. The intent on
23021 all these points has always been clear, and GNAT has always implemented the
23022 correct intended semantics.
23023
23024 @noindent
23025 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)
23026
23027 @item
23028 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
23029 @cindex AI-0044 (Ada 2012 feature)
23030
23031 @noindent
23032 This AI places restrictions on allowed instantiations of generic containers.
23033 These restrictions are not checked by the compiler, so there is nothing to
23034 change in the implementation. This affects only the RM documentation.
23035
23036 @noindent
23037 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)
23038
23039 @item
23040 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
23041 @cindex AI-0127 (Ada 2012 feature)
23042
23043 @noindent
23044 This package provides an interface for identifying the current locale.
23045
23046 @noindent
23047 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
23048 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
23049
23050
23051
23052 @item
23053 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
23054 @cindex AI-0002 (Ada 2012 feature)
23055
23056 @noindent
23057 The compiler is not required to support exporting an Ada subprogram with
23058 convention C if there are parameters or a return type of an unconstrained
23059 array type (such as @code{String}). GNAT allows such declarations but
23060 generates warnings. It is possible, but complicated, to write the
23061 corresponding C code and certainly such code would be specific to GNAT and
23062 non-portable.
23063
23064 @noindent
23065 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
23066
23067
23068 @item
23069 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
23070 @cindex AI05-0216 (Ada 2012 feature)
23071
23072 @noindent
23073 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
23074 forbid tasks declared locally within subprograms, or functions returning task
23075 objects, and that is the implementation that GNAT has always provided.
23076 However the language in the RM was not sufficiently clear on this point.
23077 Thus this is a documentation change in the RM only.
23078
23079 @noindent
23080 RM References: D.07 (3/3)
23081
23082 @item
23083 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
23084 @cindex AI-0211 (Ada 2012 feature)
23085
23086 @noindent
23087 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
23088 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
23089
23090 @noindent
23091 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
23092
23093 @item
23094 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
23095 @cindex AI-0190 (Ada 2012 feature)
23096
23097 @noindent
23098 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
23099 used to control storage pools globally.
23100 In particular, you can force every access
23101 type that is used for allocation (@b{new}) to have an explicit storage pool,
23102 or you can declare a pool globally to be used for all access types that lack
23103 an explicit one.
23104
23105 @noindent
23106 RM References: D.07 (8)
23107
23108 @item
23109 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
23110 @cindex AI-0189 (Ada 2012 feature)
23111
23112 @noindent
23113 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
23114 which says that no dynamic allocation will occur once elaboration is
23115 completed.
23116 In general this requires a run-time check, which is not required, and which
23117 GNAT does not attempt. But the static cases of allocators in a task body or
23118 in the body of the main program are detected and flagged at compile or bind
23119 time.
23120
23121 @noindent
23122 RM References: D.07 (19.1/2) H.04 (23.3/2)
23123
23124 @item
23125 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
23126 @cindex AI-0171 (Ada 2012 feature)
23127
23128 @noindent
23129 A new package @code{System.Multiprocessors} is added, together with the
23130 definition of pragma @code{CPU} for controlling task affinity. A new no
23131 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
23132 is added to the Ravenscar profile.
23133
23134 @noindent
23135 RM References: D.13.01 (4/2) D.16
23136
23137
23138 @item
23139 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
23140 @cindex AI-0210 (Ada 2012 feature)
23141
23142 @noindent
23143 This is a documentation only issue regarding wording of metric requirements,
23144 that does not affect the implementation of the compiler.
23145
23146 @noindent
23147 RM References: D.15 (24/2)
23148
23149
23150 @item
23151 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
23152 @cindex AI-0206 (Ada 2012 feature)
23153
23154 @noindent
23155 Remote types packages are now allowed to depend on preelaborated packages.
23156 This was formerly considered illegal.
23157
23158 @noindent
23159 RM References: E.02.02 (6)
23160
23161
23162
23163 @item
23164 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
23165 @cindex AI-0152 (Ada 2012 feature)
23166
23167 @noindent
23168 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
23169 where the type of the returned value is an anonymous access type.
23170
23171 @noindent
23172 RM References: H.04 (8/1)
23173 @end itemize
23174
23175
23176 @node Obsolescent Features
23177 @chapter Obsolescent Features
23178
23179 @noindent
23180 This chapter describes features that are provided by GNAT, but are
23181 considered obsolescent since there are preferred ways of achieving
23182 the same effect. These features are provided solely for historical
23183 compatibility purposes.
23184
23185 @menu
23186 * pragma No_Run_Time::
23187 * pragma Ravenscar::
23188 * pragma Restricted_Run_Time::
23189 * pragma Task_Info::
23190 * System.Task_Info (s-tasinf.ads)::
23191 @end menu
23192
23193 @node pragma No_Run_Time
23194 @section pragma No_Run_Time
23195
23196 The pragma @code{No_Run_Time} is used to achieve an affect similar
23197 to the use of the "Zero Foot Print" configurable run time, but without
23198 requiring a specially configured run time. The result of using this
23199 pragma, which must be used for all units in a partition, is to restrict
23200 the use of any language features requiring run-time support code. The
23201 preferred usage is to use an appropriately configured run-time that
23202 includes just those features that are to be made accessible.
23203
23204 @node pragma Ravenscar
23205 @section pragma Ravenscar
23206
23207 The pragma @code{Ravenscar} has exactly the same effect as pragma
23208 @code{Profile (Ravenscar)}. The latter usage is preferred since it
23209 is part of the new Ada 2005 standard.
23210
23211 @node pragma Restricted_Run_Time
23212 @section pragma Restricted_Run_Time
23213
23214 The pragma @code{Restricted_Run_Time} has exactly the same effect as
23215 pragma @code{Profile (Restricted)}. The latter usage is
23216 preferred since the Ada 2005 pragma @code{Profile} is intended for
23217 this kind of implementation dependent addition.
23218
23219 @node pragma Task_Info
23220 @section pragma Task_Info
23221
23222 The functionality provided by pragma @code{Task_Info} is now part of the
23223 Ada language. The @code{CPU} aspect and the package
23224 @code{System.Multiprocessors} offer a less system-dependent way to specify
23225 task affinity or to query the number of processsors.
23226
23227 @noindent
23228 Syntax
23229
23230 @smallexample @c ada
23231 pragma Task_Info (EXPRESSION);
23232 @end smallexample
23233
23234 @noindent
23235 This pragma appears within a task definition (like pragma
23236 @code{Priority}) and applies to the task in which it appears. The
23237 argument must be of type @code{System.Task_Info.Task_Info_Type}.
23238 The @code{Task_Info} pragma provides system dependent control over
23239 aspects of tasking implementation, for example, the ability to map
23240 tasks to specific processors. For details on the facilities available
23241 for the version of GNAT that you are using, see the documentation
23242 in the spec of package System.Task_Info in the runtime
23243 library.
23244
23245 @node System.Task_Info (s-tasinf.ads)
23246 @section package System.Task_Info (@file{s-tasinf.ads})
23247
23248 @noindent
23249 This package provides target dependent functionality that is used
23250 to support the @code{Task_Info} pragma. The predefined Ada package
23251 @code{System.Multiprocessors} and the @code{CPU} aspect now provide a
23252 standard replacement for GNAT's @code{Task_Info} functionality.
23253
23254 @include fdl.texi
23255 @c GNU Free Documentation License
23256
23257 @node Concept Index
23258 @unnumbered Index
23259
23260 @printindex cp
23261
23262 @contents
23263
23264 @bye