2015-02-20 Arnaud Charlet <charlet@adacore.com>
[official-gcc.git] / gcc / ada / doc / gnat_rm / implementation_defined_attributes.rst
blobb25f9c996a60d32b9e879ff9beb115e32a5e6d5d
1 .. _Implementation_Defined_Attributes:
3 *********************************
4 Implementation Defined Attributes
5 *********************************
7 Ada defines (throughout the Ada reference manual,
8 summarized in Annex K),
9 a set of attributes that provide useful additional functionality in all
10 areas of the language.  These language defined attributes are implemented
11 in GNAT and work as described in the Ada Reference Manual.
13 In addition, Ada allows implementations to define additional
14 attributes whose meaning is defined by the implementation.  GNAT provides
15 a number of these implementation-dependent attributes which can be used
16 to extend and enhance the functionality of the compiler.  This section of
17 the GNAT reference manual describes these additional attributes.  It also
18 describes additional implementation-dependent features of standard
19 language-defined attributes.
21 Note that any program using these attributes may not be portable to
22 other compilers (although GNAT implements this set of attributes on all
23 platforms).  Therefore if portability to other compilers is an important
24 consideration, you should minimize the use of these attributes.
26 Attribute Abort_Signal
27 ======================
28 .. index:: Abort_Signal
30 `Standard'Abort_Signal` (`Standard` is the only allowed
31 prefix) provides the entity for the special exception used to signal
32 task abort or asynchronous transfer of control.  Normally this attribute
33 should only be used in the tasking runtime (it is highly peculiar, and
34 completely outside the normal semantics of Ada, for a user program to
35 intercept the abort exception).
37 Attribute Address_Size
38 ======================
39 .. index:: Size of `Address`
41 .. index:: Address_Size
43 `Standard'Address_Size` (`Standard` is the only allowed
44 prefix) is a static constant giving the number of bits in an
45 `Address`. It is the same value as System.Address'Size,
46 but has the advantage of being static, while a direct
47 reference to System.Address'Size is non-static because Address
48 is a private type.
50 Attribute Asm_Input
51 ===================
52 .. index:: Asm_Input
54 The `Asm_Input` attribute denotes a function that takes two
55 parameters.  The first is a string, the second is an expression of the
56 type designated by the prefix.  The first (string) argument is required
57 to be a static expression, and is the constraint for the parameter,
58 (e.g., what kind of register is required).  The second argument is the
59 value to be used as the input argument.  The possible values for the
60 constant are the same as those used in the RTL, and are dependent on
61 the configuration file used to built the GCC back end.
62 :ref:`Machine_Code_Insertions`
64 Attribute Asm_Output
65 ====================
66 .. index:: Asm_Output
68 The `Asm_Output` attribute denotes a function that takes two
69 parameters.  The first is a string, the second is the name of a variable
70 of the type designated by the attribute prefix.  The first (string)
71 argument is required to be a static expression and designates the
72 constraint for the parameter (e.g., what kind of register is
73 required).  The second argument is the variable to be updated with the
74 result.  The possible values for constraint are the same as those used in
75 the RTL, and are dependent on the configuration file used to build the
76 GCC back end.  If there are no output operands, then this argument may
77 either be omitted, or explicitly given as `No_Output_Operands`.
78 :ref:`Machine_Code_Insertions`
80 Attribute Atomic_Always_Lock_Free
81 =================================
82 .. index:: Atomic_Always_Lock_Free
84 The prefix of the `Atomic_Always_Lock_Free` attribute is a type.
85 The result is a Boolean value which is True if the type has discriminants,
86 and False otherwise.  The result indicate whether atomic operations are
87 supported by the target for the given type.
89 Attribute Bit
90 =============
91 .. index:: Bit
93 ``obj'Bit``, where `obj` is any object, yields the bit
94 offset within the storage unit (byte) that contains the first bit of
95 storage allocated for the object.  The value of this attribute is of the
96 type `Universal_Integer`, and is always a non-negative number not
97 exceeding the value of `System.Storage_Unit`.
99 For an object that is a variable or a constant allocated in a register,
100 the value is zero.  (The use of this attribute does not force the
101 allocation of a variable to memory).
103 For an object that is a formal parameter, this attribute applies
104 to either the matching actual parameter or to a copy of the
105 matching actual parameter.
107 For an access object the value is zero.  Note that
108 ``obj.all'Bit`` is subject to an `Access_Check` for the
109 designated object.  Similarly for a record component
110 ``X.C'Bit`` is subject to a discriminant check and
111 ``X(I).Bit`` and ``X(I1..I2)'Bit``
112 are subject to index checks.
114 This attribute is designed to be compatible with the DEC Ada 83 definition
115 and implementation of the `Bit` attribute.
117 Attribute Bit_Position
118 ======================
119 .. index:: Bit_Position
121 ``R.C'Bit_Position``, where `R` is a record object and `C` is one
122 of the fields of the record type, yields the bit
123 offset within the record contains the first bit of
124 storage allocated for the object.  The value of this attribute is of the
125 type `Universal_Integer`.  The value depends only on the field
126 `C` and is independent of the alignment of
127 the containing record `R`.
129 Attribute Code_Address
130 ======================
131 .. index:: Code_Address
132 .. index:: Subprogram address
134 .. index:: Address of subprogram code
136 The `'Address`
137 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
138 intended effect seems to be to provide
139 an address value which can be used to call the subprogram by means of
140 an address clause as in the following example:
142 .. code-block:: ada
144   procedure K is ...
146   procedure L;
147   for L'Address use K'Address;
148   pragma Import (Ada, L);
149   
151 A call to `L` is then expected to result in a call to `K`.
152 In Ada 83, where there were no access-to-subprogram values, this was
153 a common work-around for getting the effect of an indirect call.
154 GNAT implements the above use of `Address` and the technique
155 illustrated by the example code works correctly.
157 However, for some purposes, it is useful to have the address of the start
158 of the generated code for the subprogram.  On some architectures, this is
159 not necessarily the same as the `Address` value described above.
160 For example, the `Address` value may reference a subprogram
161 descriptor rather than the subprogram itself.
163 The `'Code_Address` attribute, which can only be applied to
164 subprogram entities, always returns the address of the start of the
165 generated code of the specified subprogram, which may or may not be
166 the same value as is returned by the corresponding `'Address`
167 attribute.
169 Attribute Compiler_Version
170 ==========================
171 .. index:: Compiler_Version
173 `Standard'Compiler_Version` (`Standard` is the only allowed
174 prefix) yields a static string identifying the version of the compiler
175 being used to compile the unit containing the attribute reference.
177 Attribute Constrained
178 =====================
179 .. index:: Constrained
181 In addition to the usage of this attribute in the Ada RM, `GNAT`
182 also permits the use of the `'Constrained` attribute
183 in a generic template
184 for any type, including types without discriminants. The value of this
185 attribute in the generic instance when applied to a scalar type or a
186 record type without discriminants is always `True`. This usage is
187 compatible with older Ada compilers, including notably DEC Ada.
189 Attribute Default_Bit_Order
190 ===========================
191 .. index:: Big endian
193 .. index:: Little endian
195 .. index:: Default_Bit_Order
197 `Standard'Default_Bit_Order` (`Standard` is the only
198 permissible prefix), provides the value `System.Default_Bit_Order`
199 as a `Pos` value (0 for `High_Order_First`, 1 for
200 `Low_Order_First`).  This is used to construct the definition of
201 `Default_Bit_Order` in package `System`.
203 Attribute Default_Scalar_Storage_Order
204 ======================================
205 .. index:: Big endian
207 .. index:: Little endian
209 .. index:: Default_Scalar_Storage_Order
211 `Standard'Default_Scalar_Storage_Order` (`Standard` is the only
212 permissible prefix), provides the current value of the default scalar storage
213 order (as specified using pragma `Default_Scalar_Storage_Order`, or
214 equal to `Default_Bit_Order` if unspecified) as a
215 `System.Bit_Order` value. This is a static attribute.
217 Attribute Descriptor_Size
218 =========================
219 .. index:: Descriptor
221 .. index:: Dope vector
223 .. index:: Descriptor_Size
225 Non-static attribute `Descriptor_Size` returns the size in bits of the
226 descriptor allocated for a type.  The result is non-zero only for unconstrained
227 array types and the returned value is of type universal integer.  In GNAT, an
228 array descriptor contains bounds information and is located immediately before
229 the first element of the array.
231 .. code-block:: ada
233   type Unconstr_Array is array (Positive range <>) of Boolean;
234   Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
235   
237 The attribute takes into account any additional padding due to type alignment.
238 In the example above, the descriptor contains two values of type
239 `Positive` representing the low and high bound.  Since `Positive` has
240 a size of 31 bits and an alignment of 4, the descriptor size is `2 * Positive'Size + 2` or 64 bits.
242 Attribute Elaborated
243 ====================
244 .. index:: Elaborated
246 The prefix of the `'Elaborated` attribute must be a unit name.  The
247 value is a Boolean which indicates whether or not the given unit has been
248 elaborated.  This attribute is primarily intended for internal use by the
249 generated code for dynamic elaboration checking, but it can also be used
250 in user programs.  The value will always be True once elaboration of all
251 units has been completed.  An exception is for units which need no
252 elaboration, the value is always False for such units.
254 Attribute Elab_Body
255 ===================
256 .. index:: Elab_Body
258 This attribute can only be applied to a program unit name.  It returns
259 the entity for the corresponding elaboration procedure for elaborating
260 the body of the referenced unit.  This is used in the main generated
261 elaboration procedure by the binder and is not normally used in any
262 other context.  However, there may be specialized situations in which it
263 is useful to be able to call this elaboration procedure from Ada code,
264 e.g., if it is necessary to do selective re-elaboration to fix some
265 error.
267 Attribute Elab_Spec
268 ===================
269 .. index:: Elab_Spec
271 This attribute can only be applied to a program unit name.  It returns
272 the entity for the corresponding elaboration procedure for elaborating
273 the spec of the referenced unit.  This is used in the main
274 generated elaboration procedure by the binder and is not normally used
275 in any other context.  However, there may be specialized situations in
276 which it is useful to be able to call this elaboration procedure from
277 Ada code, e.g., if it is necessary to do selective re-elaboration to fix
278 some error.
280 Attribute Elab_Subp_Body
281 ========================
282 .. index:: Elab_Subp_Body
284 This attribute can only be applied to a library level subprogram
285 name and is only allowed in CodePeer mode. It returns the entity
286 for the corresponding elaboration procedure for elaborating the body
287 of the referenced subprogram unit. This is used in the main generated
288 elaboration procedure by the binder in CodePeer mode only and is unrecognized
289 otherwise.
291 Attribute Emax
292 ==============
293 .. index:: Ada 83 attributes
295 .. index:: Emax
297 The `Emax` attribute is provided for compatibility with Ada 83.  See
298 the Ada 83 reference manual for an exact description of the semantics of
299 this attribute.
301 Attribute Enabled
302 =================
303 .. index:: Enabled
305 The `Enabled` attribute allows an application program to check at compile
306 time to see if the designated check is currently enabled. The prefix is a
307 simple identifier, referencing any predefined check name (other than
308 `All_Checks`) or a check name introduced by pragma Check_Name. If
309 no argument is given for the attribute, the check is for the general state
310 of the check, if an argument is given, then it is an entity name, and the
311 check indicates whether an `Suppress` or `Unsuppress` has been
312 given naming the entity (if not, then the argument is ignored).
314 Note that instantiations inherit the check status at the point of the
315 instantiation, so a useful idiom is to have a library package that
316 introduces a check name with `pragma Check_Name`, and then contains
317 generic packages or subprograms which use the `Enabled` attribute
318 to see if the check is enabled. A user of this package can then issue
319 a `pragma Suppress` or `pragma Unsuppress` before instantiating
320 the package or subprogram, controlling whether the check will be present.
322 Attribute Enum_Rep
323 ==================
324 .. index:: Representation of enums
326 .. index:: Enum_Rep
328 For every enumeration subtype `S`, ``S'Enum_Rep`` denotes a
329 function with the following spec:
331 .. code-block:: ada
333   function S'Enum_Rep (Arg : S'Base) return <Universal_Integer>;
334   
336 It is also allowable to apply `Enum_Rep` directly to an object of an
337 enumeration type or to a non-overloaded enumeration
338 literal.  In this case ``S'Enum_Rep`` is equivalent to
339 ``typ'Enum_Rep(S)`` where `typ` is the type of the
340 enumeration literal or object.
342 The function returns the representation value for the given enumeration
343 value.  This will be equal to value of the `Pos` attribute in the
344 absence of an enumeration representation clause.  This is a static
345 attribute (i.e.,:the result is static if the argument is static).
347 ``S'Enum_Rep`` can also be used with integer types and objects,
348 in which case it simply returns the integer value.  The reason for this
349 is to allow it to be used for `(<>)` discrete formal arguments in
350 a generic unit that can be instantiated with either enumeration types
351 or integer types.  Note that if `Enum_Rep` is used on a modular
352 type whose upper bound exceeds the upper bound of the largest signed
353 integer type, and the argument is a variable, so that the universal
354 integer calculation is done at run time, then the call to `Enum_Rep`
355 may raise `Constraint_Error`.
357 Attribute Enum_Val
358 ==================
359 .. index:: Representation of enums
361 .. index:: Enum_Val
363 For every enumeration subtype `S`, ``S'Enum_Val`` denotes a
364 function with the following spec:
366 .. code-block:: ada
368   function S'Enum_Val (Arg : <Universal_Integer>) return S'Base;
369   
371 The function returns the enumeration value whose representation matches the
372 argument, or raises Constraint_Error if no enumeration literal of the type
373 has the matching value.
374 This will be equal to value of the `Val` attribute in the
375 absence of an enumeration representation clause.  This is a static
376 attribute (i.e., the result is static if the argument is static).
378 Attribute Epsilon
379 =================
380 .. index:: Ada 83 attributes
382 .. index:: Epsilon
384 The `Epsilon` attribute is provided for compatibility with Ada 83.  See
385 the Ada 83 reference manual for an exact description of the semantics of
386 this attribute.
388 Attribute Fast_Math
389 ===================
390 .. index:: Fast_Math
392 `Standard'Fast_Math` (`Standard` is the only allowed
393 prefix) yields a static Boolean value that is True if pragma
394 `Fast_Math` is active, and False otherwise.
396 Attribute Fixed_Value
397 =====================
398 .. index:: Fixed_Value
400 For every fixed-point type `S`, ``S'Fixed_Value`` denotes a
401 function with the following specification:
403 .. code-block:: ada
405   function S'Fixed_Value (Arg : <Universal_Integer>) return S;
406   
407 The value returned is the fixed-point value `V` such that::
409   V = Arg * S'Small
410   
412 The effect is thus similar to first converting the argument to the
413 integer type used to represent `S`, and then doing an unchecked
414 conversion to the fixed-point type.  The difference is
415 that there are full range checks, to ensure that the result is in range.
416 This attribute is primarily intended for use in implementation of the
417 input-output functions for fixed-point values.
419 Attribute From_Any
420 ==================
421 .. index:: From_Any
423 This internal attribute is used for the generation of remote subprogram
424 stubs in the context of the Distributed Systems Annex.
426 Attribute Has_Access_Values
427 ===========================
428 .. index:: Access values, testing for
430 .. index:: Has_Access_Values
432 The prefix of the `Has_Access_Values` attribute is a type.  The result
433 is a Boolean value which is True if the is an access type, or is a composite
434 type with a component (at any nesting depth) that is an access type, and is
435 False otherwise.
436 The intended use of this attribute is in conjunction with generic
437 definitions.  If the attribute is applied to a generic private type, it
438 indicates whether or not the corresponding actual type has access values.
440 Attribute Has_Discriminants
441 ===========================
442 .. index:: Discriminants, testing for
444 .. index:: Has_Discriminants
446 The prefix of the `Has_Discriminants` attribute is a type.  The result
447 is a Boolean value which is True if the type has discriminants, and False
448 otherwise.  The intended use of this attribute is in conjunction with generic
449 definitions.  If the attribute is applied to a generic private type, it
450 indicates whether or not the corresponding actual type has discriminants.
452 Attribute Img
453 =============
454 .. index:: Img
456 The `Img` attribute differs from `Image` in that it is applied
457 directly to an object, and yields the same result as
458 `Image` for the subtype of the object.  This is convenient for
459 debugging:
461 .. code-block:: ada
463   Put_Line ("X = " & X'Img);
464   
466 has the same meaning as the more verbose:
468 .. code-block:: ada
470   Put_Line ("X = " & T'Image (X));
471   
472 where `T` is the (sub)type of the object `X`.
474 Note that technically, in analogy to `Image`,
475 `X'Img` returns a parameterless function
476 that returns the appropriate string when called. This means that
477 `X'Img` can be renamed as a function-returning-string, or used
478 in an instantiation as a function parameter.
480 Attribute Integer_Value
481 =======================
482 .. index:: Integer_Value
484 For every integer type `S`, ``S'Integer_Value`` denotes a
485 function with the following spec:
487 .. code-block:: ada
489   function S'Integer_Value (Arg : <Universal_Fixed>) return S;
491 The value returned is the integer value `V`, such that::
493   Arg = V * T'Small
494   
496 where `T` is the type of `Arg`.
497 The effect is thus similar to first doing an unchecked conversion from
498 the fixed-point type to its corresponding implementation type, and then
499 converting the result to the target integer type.  The difference is
500 that there are full range checks, to ensure that the result is in range.
501 This attribute is primarily intended for use in implementation of the
502 standard input-output functions for fixed-point values.
504 Attribute Invalid_Value
505 =======================
506 .. index:: Invalid_Value
508 For every scalar type S, S'Invalid_Value returns an undefined value of the
509 type. If possible this value is an invalid representation for the type. The
510 value returned is identical to the value used to initialize an otherwise
511 uninitialized value of the type if pragma Initialize_Scalars is used,
512 including the ability to modify the value with the binder -Sxx flag and
513 relevant environment variables at run time.
515 Attribute Iterable
516 ==================
517 .. index:: Iterable
519 Equivalent to Aspect Iterable.
521 Attribute Large
522 ===============
523 .. index:: Ada 83 attributes
525 .. index:: Large
527 The `Large` attribute is provided for compatibility with Ada 83.  See
528 the Ada 83 reference manual for an exact description of the semantics of
529 this attribute.
531 Attribute Library_Level
532 =======================
533 .. index:: Library_Level
535 `P'Library_Level`, where P is an entity name,
536 returns a Boolean value which is True if the entity is declared
537 at the library level, and False otherwise. Note that within a
538 generic instantition, the name of the generic unit denotes the
539 instance, which means that this attribute can be used to test
540 if a generic is instantiated at the library level, as shown
541 in this example:
543 .. code-block:: ada
545   generic
546     ...
547   package Gen is
548     pragma Compile_Time_Error
549       (not Gen'Library_Level,
550        "Gen can only be instantiated at library level");
551     ...
552   end Gen;
553   
555 Attribute Lock_Free
556 ===================
557 .. index:: Lock_Free
559 `P'Lock_Free`, where P is a protected object, returns True if a
560 pragma `Lock_Free` applies to P.
562 Attribute Loop_Entry
563 ====================
564 .. index:: Loop_Entry
566 Syntax::
568   X'Loop_Entry [(loop_name)]
569   
571 The `Loop_Entry` attribute is used to refer to the value that an
572 expression had upon entry to a given loop in much the same way that the
573 `Old` attribute in a subprogram postcondition can be used to refer
574 to the value an expression had upon entry to the subprogram. The
575 relevant loop is either identified by the given loop name, or it is the
576 innermost enclosing loop when no loop name is given.
578 A `Loop_Entry` attribute can only occur within a
579 `Loop_Variant` or `Loop_Invariant` pragma. A common use of
580 `Loop_Entry` is to compare the current value of objects with their
581 initial value at loop entry, in a `Loop_Invariant` pragma.
583 The effect of using `X'Loop_Entry` is the same as declaring
584 a constant initialized with the initial value of `X` at loop
585 entry. This copy is not performed if the loop is not entered, or if the
586 corresponding pragmas are ignored or disabled.
588 Attribute Machine_Size
589 ======================
590 .. index:: Machine_Size
592 This attribute is identical to the `Object_Size` attribute.  It is
593 provided for compatibility with the DEC Ada 83 attribute of this name.
595 Attribute Mantissa
596 ==================
597 .. index:: Ada 83 attributes
599 .. index:: Mantissa
601 The `Mantissa` attribute is provided for compatibility with Ada 83.  See
602 the Ada 83 reference manual for an exact description of the semantics of
603 this attribute.
605 .. _Attribute_Maximum_Alignment:
607 Attribute Maximum_Alignment
608 ===========================
609 .. index:: Alignment, maximum
611 .. index:: Maximum_Alignment
613 `Standard'Maximum_Alignment` (`Standard` is the only
614 permissible prefix) provides the maximum useful alignment value for the
615 target.  This is a static value that can be used to specify the alignment
616 for an object, guaranteeing that it is properly aligned in all
617 cases.
619 Attribute Mechanism_Code
620 ========================
621 .. index:: Return values, passing mechanism
623 .. index:: Parameters, passing mechanism
625 .. index:: Mechanism_Code
627 ``function'Mechanism_Code`` yields an integer code for the
628 mechanism used for the result of function, and
629 ``subprogram'Mechanism_Code (n)`` yields the mechanism
630 used for formal parameter number `n` (a static integer value with 1
631 meaning the first parameter) of `subprogram`.  The code returned is:
636   by copy (value)
639   by reference
641 Attribute Null_Parameter
642 ========================
643 .. index:: Zero address, passing
645 .. index:: Null_Parameter
647 A reference ``T'Null_Parameter`` denotes an imaginary object of
648 type or subtype `T` allocated at machine address zero.  The attribute
649 is allowed only as the default expression of a formal parameter, or as
650 an actual expression of a subprogram call.  In either case, the
651 subprogram must be imported.
653 The identity of the object is represented by the address zero in the
654 argument list, independent of the passing mechanism (explicit or
655 default).
657 This capability is needed to specify that a zero address should be
658 passed for a record or other composite object passed by reference.
659 There is no way of indicating this without the `Null_Parameter`
660 attribute.
662 Attribute Object_Size
663 =====================
664 .. index:: Size, used for objects
666 .. index:: Object_Size
668 The size of an object is not necessarily the same as the size of the type
669 of an object.  This is because by default object sizes are increased to be
670 a multiple of the alignment of the object.  For example,
671 `Natural'Size` is
672 31, but by default objects of type `Natural` will have a size of 32 bits.
673 Similarly, a record containing an integer and a character:
675 .. code-block:: ada
677   type Rec is record
678      I : Integer;
679      C : Character;
680   end record;
681   
683 will have a size of 40 (that is `Rec'Size` will be 40).  The
684 alignment will be 4, because of the
685 integer field, and so the default size of record objects for this type
686 will be 64 (8 bytes).
688 If the alignment of the above record is specified to be 1, then the
689 object size will be 40 (5 bytes). This is true by default, and also
690 an object size of 40 can be explicitly specified in this case.
692 A consequence of this capability is that different object sizes can be
693 given to subtypes that would otherwise be considered in Ada to be
694 statically matching.  But it makes no sense to consider such subtypes
695 as statically matching.  Consequently, in `GNAT` we add a rule
696 to the static matching rules that requires object sizes to match.
697 Consider this example:
699 .. code-block:: ada
701    1. procedure BadAVConvert is
702    2.    type R is new Integer;
703    3.    subtype R1 is R range 1 .. 10;
704    4.    subtype R2 is R range 1 .. 10;
705    5.    for R1'Object_Size use 8;
706    6.    for R2'Object_Size use 16;
707    7.    type R1P is access all R1;
708    8.    type R2P is access all R2;
709    9.    R1PV : R1P := new R1'(4);
710   10.    R2PV : R2P;
711   11. begin
712   12.    R2PV := R2P (R1PV);
713                  |
714          >>> target designated subtype not compatible with
715              type "R1" defined at line 3
717   13. end;
718   
720 In the absence of lines 5 and 6,
721 types `R1` and `R2` statically match and
722 hence the conversion on line 12 is legal. But since lines 5 and 6
723 cause the object sizes to differ, `GNAT` considers that types
724 `R1` and `R2` are not statically matching, and line 12
725 generates the diagnostic shown above.
727 Similar additional checks are performed in other contexts requiring
728 statically matching subtypes.
730 Attribute Old
731 =============
732 .. index:: Old
734 In addition to the usage of `Old` defined in the Ada 2012 RM (usage
735 within `Post` aspect), GNAT also permits the use of this attribute
736 in implementation defined pragmas `Postcondition`,
737 `Contract_Cases` and `Test_Case`. Also usages of
738 `Old` which would be illegal according to the Ada 2012 RM
739 definition are allowed under control of
740 implementation defined pragma `Unevaluated_Use_Of_Old`.
742 Attribute Passed_By_Reference
743 =============================
744 .. index:: Parameters, when passed by reference
746 .. index:: Passed_By_Reference
748 ``type'Passed_By_Reference`` for any subtype `type` returns
749 a value of type `Boolean` value that is `True` if the type is
750 normally passed by reference and `False` if the type is normally
751 passed by copy in calls.  For scalar types, the result is always `False`
752 and is static.  For non-scalar types, the result is non-static.
754 Attribute Pool_Address
755 ======================
756 .. index:: Parameters, when passed by reference
758 .. index:: Pool_Address
760 ``X'Pool_Address`` for any object `X` returns the address
761 of X within its storage pool. This is the same as
762 ``X'Address``, except that for an unconstrained array whose
763 bounds are allocated just before the first component,
764 ``X'Pool_Address`` returns the address of those bounds,
765 whereas ``X'Address`` returns the address of the first
766 component.
768 Here, we are interpreting 'storage pool' broadly to mean 
769 ``wherever the object is allocated``, which could be a 
770 user-defined storage pool,
771 the global heap, on the stack, or in a static memory area.
772 For an object created by `new`, ``Ptr.all'Pool_Address`` is
773 what is passed to `Allocate` and returned from `Deallocate`.
775 Attribute Range_Length
776 ======================
777 .. index:: Range_Length
779 ``type'Range_Length`` for any discrete type `type` yields
780 the number of values represented by the subtype (zero for a null
781 range).  The result is static for static subtypes.  `Range_Length`
782 applied to the index subtype of a one dimensional array always gives the
783 same result as `Length` applied to the array itself.
785 Attribute Ref
786 =============
787 .. index:: Ref
789 Attribute Restriction_Set
790 =========================
791 .. index:: Restriction_Set
792 .. index:: Restrictions
794 This attribute allows compile time testing of restrictions that
795 are currently in effect. It is primarily intended for specializing
796 code in the run-time based on restrictions that are active (e.g.
797 don't need to save fpt registers if restriction No_Floating_Point
798 is known to be in effect), but can be used anywhere.
800 There are two forms:
802 .. code-block:: ada
804   System'Restriction_Set (partition_boolean_restriction_NAME)
805   System'Restriction_Set (No_Dependence => library_unit_NAME);
806   
808 In the case of the first form, the only restriction names
809 allowed are parameterless restrictions that are checked
810 for consistency at bind time. For a complete list see the
811 subtype `System.Rident.Partition_Boolean_Restrictions`.
813 The result returned is True if the restriction is known to
814 be in effect, and False if the restriction is known not to
815 be in effect. An important guarantee is that the value of
816 a Restriction_Set attribute is known to be consistent throughout
817 all the code of a partition.
819 This is trivially achieved if the entire partition is compiled
820 with a consistent set of restriction pragmas. However, the
821 compilation model does not require this. It is possible to
822 compile one set of units with one set of pragmas, and another
823 set of units with another set of pragmas. It is even possible
824 to compile a spec with one set of pragmas, and then WITH the
825 same spec with a different set of pragmas. Inconsistencies
826 in the actual use of the restriction are checked at bind time.
828 In order to achieve the guarantee of consistency for the
829 Restriction_Set pragma, we consider that a use of the pragma
830 that yields False is equivalent to a violation of the
831 restriction.
833 So for example if you write
835 .. code-block:: ada
837   if System'Restriction_Set (No_Floating_Point) then
838      ...
839   else
840      ...
841   end if;
842   
844 And the result is False, so that the else branch is executed,
845 you can assume that this restriction is not set for any unit
846 in the partition. This is checked by considering this use of
847 the restriction pragma to be a violation of the restriction
848 No_Floating_Point. This means that no other unit can attempt
849 to set this restriction (if some unit does attempt to set it,
850 the binder will refuse to bind the partition).
852 Technical note: The restriction name and the unit name are
853 intepreted entirely syntactically, as in the corresponding
854 Restrictions pragma, they are not analyzed semantically,
855 so they do not have a type.
857 Attribute Result
858 ================
859 .. index:: Result
861 ``function'Result`` can only be used with in a Postcondition pragma
862 for a function. The prefix must be the name of the corresponding function. This
863 is used to refer to the result of the function in the postcondition expression.
864 For a further discussion of the use of this attribute and examples of its use,
865 see the description of pragma Postcondition.
867 Attribute Safe_Emax
868 ===================
869 .. index:: Ada 83 attributes
871 .. index:: Safe_Emax
873 The `Safe_Emax` attribute is provided for compatibility with Ada 83.  See
874 the Ada 83 reference manual for an exact description of the semantics of
875 this attribute.
877 Attribute Safe_Large
878 ====================
879 .. index:: Ada 83 attributes
881 .. index:: Safe_Large
883 The `Safe_Large` attribute is provided for compatibility with Ada 83.  See
884 the Ada 83 reference manual for an exact description of the semantics of
885 this attribute.
887 Attribute Safe_Small
888 ====================
889 .. index:: Ada 83 attributes
891 .. index:: Safe_Small
893 The `Safe_Small` attribute is provided for compatibility with Ada 83.  See
894 the Ada 83 reference manual for an exact description of the semantics of
895 this attribute.
897 Attribute Scalar_Storage_Order
898 ==============================
899 .. index:: Endianness
901 .. index:: Scalar storage order
903 .. index:: Scalar_Storage_Order
905 For every array or record type `S`, the representation attribute
906 `Scalar_Storage_Order` denotes the order in which storage elements
907 that make up scalar components are ordered within S. The value given must
908 be a static expression of type System.Bit_Order. The following is an example
909 of the use of this feature:
911 .. code-block:: ada
913      --  Component type definitions
915      subtype Yr_Type is Natural range 0 .. 127;
916      subtype Mo_Type is Natural range 1 .. 12;
917      subtype Da_Type is Natural range 1 .. 31;
919      --  Record declaration
921      type Date is record
922         Years_Since_1980 : Yr_Type;
923         Month            : Mo_Type;
924         Day_Of_Month     : Da_Type;
925      end record;
927      --  Record representation clause
929      for Date use record
930         Years_Since_1980 at 0 range 0  ..  6;
931         Month            at 0 range 7  .. 10;
932         Day_Of_Month     at 0 range 11 .. 15;
933      end record;
935      --  Attribute definition clauses
937      for Date'Bit_Order use System.High_Order_First;
938      for Date'Scalar_Storage_Order use System.High_Order_First;
939      --  If Scalar_Storage_Order is specified, it must be consistent with
940      --  Bit_Order, so it's best to always define the latter explicitly if
941      --  the former is used.
942   
944 Other properties are as for standard representation attribute `Bit_Order`,
945 as defined by Ada RM 13.5.3(4). The default is `System.Default_Bit_Order`.
947 For a record type `T`, if ``T'Scalar_Storage_Order`` is
948 specified explicitly, it shall be equal to ``T'Bit_Order``. Note:
949 this means that if a `Scalar_Storage_Order` attribute definition
950 clause is not confirming, then the type's `Bit_Order` shall be
951 specified explicitly and set to the same value.
953 Derived types inherit an explicitly set scalar storage order from their parent
954 types. This may be overridden for the derived type by giving an explicit scalar
955 storage order for the derived type. For a record extension, the derived type
956 must have the same scalar storage order as the parent type.
958 If a component of `T` is of a record or array type, then that type must
959 also have a `Scalar_Storage_Order` attribute definition clause.
961 A component of a record or array type that is a packed array, or that
962 does not start on a byte boundary, must have the same scalar storage order
963 as the enclosing record or array type.
965 No component of a type that has an explicit `Scalar_Storage_Order`
966 attribute definition may be aliased.
968 A confirming `Scalar_Storage_Order` attribute definition clause (i.e.
969 with a value equal to `System.Default_Bit_Order`) has no effect.
971 If the opposite storage order is specified, then whenever the value of
972 a scalar component of an object of type `S` is read, the storage
973 elements of the enclosing machine scalar are first reversed (before
974 retrieving the component value, possibly applying some shift and mask
975 operatings on the enclosing machine scalar), and the opposite operation
976 is done for writes.
978 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
979 are relaxed. Instead, the following rules apply:
981 * the underlying storage elements are those at positions
982   `(position + first_bit / storage_element_size) ..         (position + (last_bit + storage_element_size - 1) /                     storage_element_size)`
983 * the sequence of underlying storage elements shall have
984   a size no greater than the largest machine scalar
985 * the enclosing machine scalar is defined as the smallest machine
986   scalar starting at a position no greater than
987   `position + first_bit / storage_element_size` and covering
988   storage elements at least up to `position + (last_bit +         storage_element_size - 1) / storage_element_size`
989 * the position of the component is interpreted relative to that machine
990   scalar.
992 If no scalar storage order is specified for a type (either directly, or by
993 inheritance in the case of a derived type), then the default is normally
994 the native ordering of the target, but this default can be overridden using
995 pragma `Default_Scalar_Storage_Order`.
997 Note that the scalar storage order only affects the in-memory data
998 representation. It has no effect on the representation used by stream
999 attributes.
1001 .. _Attribute_Simple_Storage_Pool:
1003 Attribute Simple_Storage_Pool
1004 =============================
1005 .. index:: Storage pool, simple
1007 .. index:: Simple storage pool
1009 .. index:: Simple_Storage_Pool
1011 For every nonformal, nonderived access-to-object type `Acc`, the
1012 representation attribute `Simple_Storage_Pool` may be specified
1013 via an attribute_definition_clause (or by specifying the equivalent aspect):
1015 .. code-block:: ada
1017   My_Pool : My_Simple_Storage_Pool_Type;
1019   type Acc is access My_Data_Type;
1021   for Acc'Simple_Storage_Pool use My_Pool;
1023   
1025 The name given in an attribute_definition_clause for the
1026 `Simple_Storage_Pool` attribute shall denote a variable of
1027 a 'simple storage pool type' (see pragma `Simple_Storage_Pool_Type`).
1029 The use of this attribute is only allowed for a prefix denoting a type
1030 for which it has been specified. The type of the attribute is the type
1031 of the variable specified as the simple storage pool of the access type,
1032 and the attribute denotes that variable.
1034 It is illegal to specify both `Storage_Pool` and `Simple_Storage_Pool`
1035 for the same access type.
1037 If the `Simple_Storage_Pool` attribute has been specified for an access
1038 type, then applying the `Storage_Pool` attribute to the type is flagged
1039 with a warning and its evaluation raises the exception `Program_Error`.
1041 If the Simple_Storage_Pool attribute has been specified for an access
1042 type `S`, then the evaluation of the attribute ``S'Storage_Size``
1043 returns the result of calling ``Storage_Size (S'Simple_Storage_Pool)``,
1044 which is intended to indicate the number of storage elements reserved for
1045 the simple storage pool. If the Storage_Size function has not been defined
1046 for the simple storage pool type, then this attribute returns zero.
1048 If an access type `S` has a specified simple storage pool of type
1049 `SSP`, then the evaluation of an allocator for that access type calls
1050 the primitive `Allocate` procedure for type `SSP`, passing
1051 ``S'Simple_Storage_Pool`` as the pool parameter. The detailed
1052 semantics of such allocators is the same as those defined for allocators
1053 in section 13.11 of the :title:`Ada Reference Manual`, with the term
1054 `simple storage pool` substituted for `storage pool`.
1056 If an access type `S` has a specified simple storage pool of type
1057 `SSP`, then a call to an instance of the `Ada.Unchecked_Deallocation`
1058 for that access type invokes the primitive `Deallocate` procedure
1059 for type `SSP`, passing ``S'Simple_Storage_Pool`` as the pool
1060 parameter. The detailed semantics of such unchecked deallocations is the same
1061 as defined in section 13.11.2 of the Ada Reference Manual, except that the
1062 term 'simple storage pool' is substituted for 'storage pool'.
1064 Attribute Small
1065 ===============
1066 .. index:: Ada 83 attributes
1068 .. index:: Small
1070 The `Small` attribute is defined in Ada 95 (and Ada 2005) only for
1071 fixed-point types.
1072 GNAT also allows this attribute to be applied to floating-point types
1073 for compatibility with Ada 83.  See
1074 the Ada 83 reference manual for an exact description of the semantics of
1075 this attribute when applied to floating-point types.
1077 Attribute Storage_Unit
1078 ======================
1079 .. index:: Storage_Unit
1081 `Standard'Storage_Unit` (`Standard` is the only permissible
1082 prefix) provides the same value as `System.Storage_Unit`.
1084 Attribute Stub_Type
1085 ===================
1086 .. index:: Stub_Type
1088 The GNAT implementation of remote access-to-classwide types is
1089 organized as described in AARM section E.4 (20.t): a value of an RACW type
1090 (designating a remote object) is represented as a normal access
1091 value, pointing to a "stub" object which in turn contains the
1092 necessary information to contact the designated remote object. A
1093 call on any dispatching operation of such a stub object does the
1094 remote call, if necessary, using the information in the stub object
1095 to locate the target partition, etc.
1097 For a prefix `T` that denotes a remote access-to-classwide type,
1098 `T'Stub_Type` denotes the type of the corresponding stub objects.
1100 By construction, the layout of `T'Stub_Type` is identical to that of
1101 type `RACW_Stub_Type` declared in the internal implementation-defined
1102 unit `System.Partition_Interface`. Use of this attribute will create
1103 an implicit dependency on this unit.
1105 Attribute System_Allocator_Alignment
1106 ====================================
1107 .. index:: Alignment, allocator
1109 .. index:: System_Allocator_Alignment
1111 `Standard'System_Allocator_Alignment` (`Standard` is the only
1112 permissible prefix) provides the observable guaranted to be honored by
1113 the system allocator (malloc). This is a static value that can be used
1114 in user storage pools based on malloc either to reject allocation
1115 with alignment too large or to enable a realignment circuitry if the
1116 alignment request is larger than this value.
1118 Attribute Target_Name
1119 =====================
1120 .. index:: Target_Name
1122 `Standard'Target_Name` (`Standard` is the only permissible
1123 prefix) provides a static string value that identifies the target
1124 for the current compilation. For GCC implementations, this is the
1125 standard gcc target name without the terminating slash (for
1126 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
1128 Attribute To_Address
1129 ====================
1130 .. index:: To_Address
1132 The `System'To_Address`
1133 (`System` is the only permissible prefix)
1134 denotes a function identical to
1135 `System.Storage_Elements.To_Address` except that
1136 it is a static attribute.  This means that if its argument is
1137 a static expression, then the result of the attribute is a
1138 static expression.  This means that such an expression can be
1139 used in contexts (e.g., preelaborable packages) which require a
1140 static expression and where the function call could not be used
1141 (since the function call is always non-static, even if its
1142 argument is static). The argument must be in the range
1143 -(2**(m-1) .. 2**m-1, where m is the memory size
1144 (typically 32 or 64). Negative values are intepreted in a
1145 modular manner (e.g., -1 means the same as 16#FFFF_FFFF# on
1146 a 32 bits machine).
1148 Attribute To_Any
1149 ================
1150 .. index:: To_Any
1152 This internal attribute is used for the generation of remote subprogram
1153 stubs in the context of the Distributed Systems Annex.
1155 Attribute Type_Class
1156 ====================
1157 .. index:: Type_Class
1159 ``type'Type_Class`` for any type or subtype `type` yields
1160 the value of the type class for the full type of `type`.  If
1161 `type` is a generic formal type, the value is the value for the
1162 corresponding actual subtype.  The value of this attribute is of type
1163 ``System.Aux_DEC.Type_Class``, which has the following definition:
1165 .. code-block:: ada
1167   type Type_Class is
1168     (Type_Class_Enumeration,
1169      Type_Class_Integer,
1170      Type_Class_Fixed_Point,
1171      Type_Class_Floating_Point,
1172      Type_Class_Array,
1173      Type_Class_Record,
1174      Type_Class_Access,
1175      Type_Class_Task,
1176      Type_Class_Address);
1177   
1179 Protected types yield the value `Type_Class_Task`, which thus
1180 applies to all concurrent types.  This attribute is designed to
1181 be compatible with the DEC Ada 83 attribute of the same name.
1183 Attribute Type_Key
1184 ==================
1185 .. index:: Type_Key
1187 The `Type_Key` attribute is applicable to a type or subtype and
1188 yields a value of type Standard.String containing encoded information
1189 about the type or subtype. This provides improved compatibility with
1190 other implementations that support this attribute.
1192 Attribute TypeCode
1193 ==================
1194 .. index:: TypeCode
1196 This internal attribute is used for the generation of remote subprogram
1197 stubs in the context of the Distributed Systems Annex.
1199 Attribute UET_Address
1200 =====================
1201 .. index:: UET_Address
1203 The `UET_Address` attribute can only be used for a prefix which
1204 denotes a library package.  It yields the address of the unit exception
1205 table when zero cost exception handling is used.  This attribute is
1206 intended only for use within the GNAT implementation.  See the unit
1207 `Ada.Exceptions` in files :file:`a-except.ads` and :file:`a-except.adb`
1208 for details on how this attribute is used in the implementation.
1210 Attribute Unconstrained_Array
1211 =============================
1212 .. index:: Unconstrained_Array
1214 The `Unconstrained_Array` attribute can be used with a prefix that
1215 denotes any type or subtype. It is a static attribute that yields
1216 `True` if the prefix designates an unconstrained array,
1217 and `False` otherwise. In a generic instance, the result is
1218 still static, and yields the result of applying this test to the
1219 generic actual.
1221 Attribute Universal_Literal_String
1222 ==================================
1223 .. index:: Named numbers, representation of
1225 .. index:: Universal_Literal_String
1227 The prefix of `Universal_Literal_String` must be a named
1228 number.  The static result is the string consisting of the characters of
1229 the number as defined in the original source.  This allows the user
1230 program to access the actual text of named numbers without intermediate
1231 conversions and without the need to enclose the strings in quotes (which
1232 would preclude their use as numbers).
1234 For example, the following program prints the first 50 digits of pi:
1236 .. code-block:: ada
1238   with Text_IO; use Text_IO;
1239   with Ada.Numerics;
1240   procedure Pi is
1241   begin
1242      Put (Ada.Numerics.Pi'Universal_Literal_String);
1243   end;
1244   
1246 Attribute Unrestricted_Access
1247 =============================
1248 .. index:: Access, unrestricted
1250 .. index:: Unrestricted_Access
1252 The `Unrestricted_Access` attribute is similar to `Access`
1253 except that all accessibility and aliased view checks are omitted.  This
1254 is a user-beware attribute.
1256 For objects, it is similar to `Address`, for which it is a
1257 desirable replacement where the value desired is an access type.
1258 In other words, its effect is similar to first applying the
1259 `Address` attribute and then doing an unchecked conversion to a
1260 desired access type.
1262 For subprograms, `P'Unrestricted_Access` may be used where
1263 `P'Access` would be illegal, to construct a value of a
1264 less-nested named access type that designates a more-nested
1265 subprogram. This value may be used in indirect calls, so long as the
1266 more-nested subprogram still exists; once the subprogram containing it
1267 has returned, such calls are erroneous. For example:
1269 .. code-block:: ada
1271   package body P is
1273      type Less_Nested is not null access procedure;
1274      Global : Less_Nested;
1276      procedure P1 is
1277      begin
1278         Global.all;
1279      end P1;
1281      procedure P2 is
1282         Local_Var : Integer;
1284         procedure More_Nested is
1285         begin
1286            ... Local_Var ...
1287         end More_Nested;
1288      begin
1289         Global := More_Nested'Unrestricted_Access;
1290         P1;
1291      end P2;
1293   end P;
1294   
1296 When P1 is called from P2, the call via Global is OK, but if P1 were
1297 called after P2 returns, it would be an erroneous use of a dangling
1298 pointer.
1300 For objects, it is possible to use `Unrestricted_Access` for any
1301 type. However, if the result is of an access-to-unconstrained array
1302 subtype, then the resulting pointer has the same scope as the context
1303 of the attribute, and must not be returned to some enclosing scope.
1304 For instance, if a function uses `Unrestricted_Access` to create
1305 an access-to-unconstrained-array and returns that value to the caller,
1306 the result will involve dangling pointers. In addition, it is only
1307 valid to create pointers to unconstrained arrays using this attribute
1308 if the pointer has the normal default 'fat' representation where a
1309 pointer has two components, one points to the array and one points to
1310 the bounds. If a size clause is used to force 'thin' representation
1311 for a pointer to unconstrained where there is only space for a single
1312 pointer, then the resulting pointer is not usable.
1314 In the simple case where a direct use of Unrestricted_Access attempts
1315 to make a thin pointer for a non-aliased object, the compiler will
1316 reject the use as illegal, as shown in the following example:
1318 .. code-block:: ada
1320   with System; use System;
1321   procedure SliceUA2 is
1322      type A is access all String;
1323      for A'Size use Standard'Address_Size;
1325      procedure P (Arg : A) is
1326      begin
1327         null;
1328      end P;
1330      X : String := "hello world!";
1331      X2 : aliased String := "hello world!";
1333      AV : A := X'Unrestricted_Access;    -- ERROR
1334                |
1335   >>> illegal use of Unrestricted_Access attribute
1336   >>> attempt to generate thin pointer to unaliased object
1338   begin
1339      P (X'Unrestricted_Access);          -- ERROR
1340         |
1341   >>> illegal use of Unrestricted_Access attribute
1342   >>> attempt to generate thin pointer to unaliased object
1344      P (X(7 .. 12)'Unrestricted_Access); -- ERROR
1345         |
1346   >>> illegal use of Unrestricted_Access attribute
1347   >>> attempt to generate thin pointer to unaliased object
1349      P (X2'Unrestricted_Access);         -- OK
1350   end;
1351   
1353 but other cases cannot be detected by the compiler, and are
1354 considered to be erroneous. Consider the following example:
1356 .. code-block:: ada
1358   with System; use System;
1359   with System; use System;
1360   procedure SliceUA is
1361      type AF is access all String;
1363      type A is access all String;
1364      for A'Size use Standard'Address_Size;
1366      procedure P (Arg : A) is
1367      begin
1368         if Arg'Length /= 6 then
1369            raise Program_Error;
1370         end if;
1371      end P;
1373      X : String := "hello world!";
1374      Y : AF := X (7 .. 12)'Unrestricted_Access;
1376   begin
1377      P (A (Y));
1378   end;
1379   
1381 A normal unconstrained array value
1382 or a constrained array object marked as aliased has the bounds in memory
1383 just before the array, so a thin pointer can retrieve both the data and
1384 the bounds.  But in this case, the non-aliased object `X` does not have the
1385 bounds before the string.  If the size clause for type `A`
1386 were not present, then the pointer
1387 would be a fat pointer, where one component is a pointer to the bounds,
1388 and all would be well.  But with the size clause present, the conversion from
1389 fat pointer to thin pointer in the call loses the bounds, and so this
1390 is erroneous, and the program likely raises a `Program_Error` exception.
1392 In general, it is advisable to completely
1393 avoid mixing the use of thin pointers and the use of
1394 `Unrestricted_Access` where the designated type is an
1395 unconstrained array.  The use of thin pointers should be restricted to
1396 cases of porting legacy code that implicitly assumes the size of pointers,
1397 and such code should not in any case be using this attribute.
1399 Another erroneous situation arises if the attribute is
1400 applied to a constant. The resulting pointer can be used to access the
1401 constant, but the effect of trying to modify a constant in this manner
1402 is not well-defined. Consider this example:
1404 .. code-block:: ada
1406   P : constant Integer := 4;
1407   type R is access all Integer;
1408   RV : R := P'Unrestricted_Access;
1409   ..
1410   RV.all := 3;
1411   
1413 Here we attempt to modify the constant P from 4 to 3, but the compiler may
1414 or may not notice this attempt, and subsequent references to P may yield
1415 either the value 3 or the value 4 or the assignment may blow up if the
1416 compiler decides to put P in read-only memory. One particular case where
1417 `Unrestricted_Access` can be used in this way is to modify the
1418 value of an `IN` parameter:
1420 .. code-block:: ada
1422   procedure K (S : in String) is
1423      type R is access all Character;
1424      RV : R := S (3)'Unrestricted_Access;
1425   begin
1426      RV.all := 'a';
1427   end;
1428   
1430 In general this is a risky approach. It may appear to "work" but such uses of
1431 `Unrestricted_Access` are potentially non-portable, even from one version
1432 of `GNAT` to another, so are best avoided if possible.
1434 Attribute Update
1435 ================
1436 .. index:: Update
1438 The `Update` attribute creates a copy of an array or record value
1439 with one or more modified components. The syntax is::
1441   PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
1442   PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION {, ARRAY_COMPONENT_ASSOCIATION } )
1443   PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
1444                   {, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION } )
1446   MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
1447   INDEX_EXPRESSION_LIST_LIST                   ::= INDEX_EXPRESSION_LIST {| INDEX_EXPRESSION_LIST }
1448   INDEX_EXPRESSION_LIST                        ::= ( EXPRESSION {, EXPRESSION } )
1449   
1451 where `PREFIX` is the name of an array or record object, the
1452 association list in parentheses does not contain an `others`
1453 choice and the box symbol `<>` may not appear in any
1454 expression. The effect is to yield a copy of the array or record value
1455 which is unchanged apart from the components mentioned in the
1456 association list, which are changed to the indicated value. The
1457 original value of the array or record value is not affected. For
1458 example:
1460 .. code-block:: ada
1462   type Arr is Array (1 .. 5) of Integer;
1463   ...
1464   Avar1 : Arr := (1,2,3,4,5);
1465   Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
1466   
1468 yields a value for `Avar2` of 1,10,20,20,5 with `Avar1`
1469 begin unmodified. Similarly:
1471 .. code-block:: ada
1473   type Rec is A, B, C : Integer;
1474   ...
1475   Rvar1 : Rec := (A => 1, B => 2, C => 3);
1476   Rvar2 : Rec := Rvar1'Update (B => 20);
1477   
1479 yields a value for `Rvar2` of (A => 1, B => 20, C => 3),
1480 with `Rvar1` being unmodifed.
1481 Note that the value of the attribute reference is computed
1482 completely before it is used. This means that if you write:
1484 .. code-block:: ada
1486   Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
1487   
1489 then the value of `Avar1` is not modified if `Function_Call`
1490 raises an exception, unlike the effect of a series of direct assignments
1491 to elements of `Avar1`. In general this requires that
1492 two extra complete copies of the object are required, which should be
1493 kept in mind when considering efficiency.
1495 The `Update` attribute cannot be applied to prefixes of a limited
1496 type, and cannot reference discriminants in the case of a record type.
1497 The accessibility level of an Update attribute result object is defined
1498 as for an aggregate.
1500 In the record case, no component can be mentioned more than once. In
1501 the array case, two overlapping ranges can appear in the association list,
1502 in which case the modifications are processed left to right.
1504 Multi-dimensional arrays can be modified, as shown by this example:
1506 .. code-block:: ada
1508   A : array (1 .. 10, 1 .. 10) of Integer;
1509   ..
1510   A := A'Update ((1, 2) => 20, (3, 4) => 30);
1511   
1513 which changes element (1,2) to 20 and (3,4) to 30.
1515 Attribute Valid_Scalars
1516 =======================
1517 .. index:: Valid_Scalars
1519 The `'Valid_Scalars` attribute is intended to make it easier to
1520 check the validity of scalar subcomponents of composite objects. It
1521 is defined for any prefix `X` that denotes an object.
1522 The value of this attribute is of the predefined type Boolean.
1523 `X'Valid_Scalars` yields True if and only if evaluation of
1524 `P'Valid` yields True for every scalar part P of X or if X has
1525 no scalar parts. It is not specified in what order the scalar parts
1526 are checked, nor whether any more are checked after any one of them
1527 is determined to be invalid. If the prefix `X` is of a class-wide
1528 type `T'Class` (where `T` is the associated specific type),
1529 or if the prefix `X` is of a specific tagged type `T`, then
1530 only the scalar parts of components of `T` are traversed; in other
1531 words, components of extensions of `T` are not traversed even if
1532 `T'Class (X)'Tag /= T'Tag` . The compiler will issue a warning if it can
1533 be determined at compile time that the prefix of the attribute has no
1534 scalar parts (e.g., if the prefix is of an access type, an interface type,
1535 an undiscriminated task type, or an undiscriminated protected type).
1537 For scalar types, `Valid_Scalars` is equivalent to `Valid`. The use
1538 of this attribute is not permitted for `Unchecked_Union` types for which
1539 in general it is not possible to determine the values of the discriminants.
1541 Note: `Valid_Scalars` can generate a lot of code, especially in the case
1542 of a large variant record. If the attribute is called in many places in the
1543 same program applied to objects of the same type, it can reduce program size
1544 to write a function with a single use of the attribute, and then call that
1545 function from multiple places.
1547 Attribute VADS_Size
1548 ===================
1549 .. index:: Size, VADS compatibility
1551 .. index:: VADS_Size
1553 The `'VADS_Size` attribute is intended to make it easier to port
1554 legacy code which relies on the semantics of `'Size` as implemented
1555 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
1556 same semantic interpretation.  In particular, `'VADS_Size` applied
1557 to a predefined or other primitive type with no Size clause yields the
1558 Object_Size (for example, `Natural'Size` is 32 rather than 31 on
1559 typical machines).  In addition `'VADS_Size` applied to an object
1560 gives the result that would be obtained by applying the attribute to
1561 the corresponding type.
1563 Attribute Value_Size
1564 ====================
1565 .. index:: Size, setting for not-first subtype
1567 .. index:: Value_Size
1569 ``type'Value_Size`` is the number of bits required to represent
1570 a value of the given subtype.  It is the same as ``type'Size``,
1571 but, unlike `Size`, may be set for non-first subtypes.
1573 Attribute Wchar_T_Size
1574 ======================
1575 .. index:: Wchar_T_Size
1577 `Standard'Wchar_T_Size` (`Standard` is the only permissible
1578 prefix) provides the size in bits of the C `wchar_t` type
1579 primarily for constructing the definition of this type in
1580 package `Interfaces.C`. The result is a static constant.
1582 Attribute Word_Size
1583 ===================
1584 .. index:: Word_Size
1586 `Standard'Word_Size` (`Standard` is the only permissible
1587 prefix) provides the value `System.Word_Size`. The result is
1588 a static constant.