[Ada] Predicates and the current instance of a subtype (AI12-0068)
gcc/ada/
* sem_attr.adb (Analyze_Attribute, Attribute_Constrained): Issue
a warning if the attribute prefix is a current instance
reference within an aspect of a type or subtype.
(Address_Checks): Replace test of Is_Object (Ent) with
Is_Object_Reference (P) so that testing for current instances
will be done.
(Eval_Attribute): Add test for current instance reference, to
ensure that we still fold array attributes when current
instances are involved, since value prefixes are allowed for
array attributes, and will now be excluded by
Is_Object_Reference.
* sem_util.ads (Is_Current_Instance_Reference_In_Type_Aspect):
New exported query function.
* sem_util.adb (Is_Object_Reference): Return False for the case
where N is a current instance reference within an
aspect_specification of a type or subtype (basically if the
reference occurs within a predicate, invariant, or DIC aspect
expression).
(Is_Current_Instance_Reference_In_Type_Aspect): New function
that tests whether a node is a reference to a current instance
formal of a predicate, invariant, or
Default_Initial_Condition (DIC) subprogram.