--- ai05s/ai05-0144-2.txt 2010/04/24 05:59:35 1.7 +++ ai05s/ai05-0144-2.txt 2010/05/04 03:44:13 1.8 @@ -1,4 +1,4 @@ -!standard 6.02 (11) 10-04-23 AI05-0144-2/05 +!standard 6.02 (11) 10-05-03 AI05-0144-2/06 !class Amendment 09-06-07 !status Amendment 2012 10-04-23 !status ARG Approved 5-0-4 10-02-26 @@ -38,63 +38,83 @@ Add after 6.2(11): -Two names or prefixes, N1 and N2, are *known to denote the same object* if: +Two names are *known to denote the same object* if: - * N1 statically denotes a part of a stand-alone object or parameter, and - N2 statically denotes the same part of the same stand-alone object or - parameter; or - - * N1 is a selected_component P1.C1 that represents a component, N2 is a - selected_component P2.C2 that represents a component, selectors C1 - and C2 are the same, and prefixes P1 and P2 are known to denote the - same object; or - - * N1 is a dereference (implicit or explicit) of P1, N2 is a dereference - (implicit or explicit) of P2, and prefixes P1 and P2 are known to denote - the same object; or - - * N1 is an indexed_component P1(I1,...), N2 is an indexed_component - P2(I2,...), the prefix P1 is known to denote the same object as the - prefix P2, and for each index of the indexed_component, I1 and I2 are - static expressions with the same value, or I1 and I2 are names that - are known to denote the same object; or + * both names statically denote the same stand-alone object + or parameter; or - * N1 and N2 are slices, their prefixes are known to denote the + * both names are selected_components, their prefixes are known to + denote the same object, and their selector_names denote the + same component; or + + * both names are dereferences (implicit or explicit), the + dereferenced names are known to denote the same object, + and both names have the same immediately enclosing statement or + declaration; or + +AARM Reason: We need the requirement to have the same enclosing statement in order +to avoid problems with renames. Consider: + + type Ref is access Some_Type; + Ptr : Ref := new Some_Type'(...); + X : Some_Type renames Ptr.all; + begin + Ptr := new Some_Type'(...); + P (Func_With_Out_Params (Ptr.all, X)); + +X and Ptr.all should not be known to denote the same object, since they denote different +allocated objects. +End AARM Reason. + + * both names are indexed_components, their prefixes are known + to denote the same object, and each of the pairs of corresponding + index values are either static expressions with the same value + or names that are known to denote the same object; or + + * both names are slices, their prefixes are known to denote the same object, and the two slices have statically matching index constraints; or + + * one of the two names statically denotes a renaming declaration + whose renamed object_name is known to denote the same object + as the other name; or + +AARM Reason: This exposes known renamings of slices, indexing, and so on +to this definition. In particular, if we have + C : Character renames S(1); +then C and S(1) are known to denote the same object. +End AARM Reason. + + * both names are known to denote the same object as a third name. + +AARM Reason: "Known to denote the same object" is intended to be an equivalence +relationship, that is, it is reflexive, symmetric, and transitive. This last bullet +is needed to make the relationship transitive. For instance, given the following +declarations: + S : String(1..10); + ONE : constant Natural := 1; + R : Character renames S(1); +the names R and S(1) are known to denote the same object by the sixth bullet, and +S(1) and S(ONE) are known to denote the same object by the fourth bullet, but we need +the last bullet for R and S(ONE) to be known to denote the same object. +END AARM Reason. - * N2 is a slice whose prefix is known to denote the same object as N1, and - the index constraint of N2 statically matches the constraint - N1'First .. N1'Last; or - - * N1 is a slice whose prefix is known to denote the same object as N2, and - the index constraint of N1 statically matches the constraint - N2'First .. N2'Last. AARM Discussion: Whether or not names or prefixes are known to denote the same object is determined statically. If the name contains some dynamic portion other than a dereference, indexed_component, or slice, it is not "known to denote the same object". - These rules make no attempt to handle overlapping slices or slices constrained - for objects that are known to denote the same object. - - These rules are intended to be symmetric: if A is known to denote the same object - as B, then reverse is also true. + These rules make no attempt to handle slices of objects that are known to be + the same when the slices have dynamic bounds (other than the trivial case of + bounds being defined by the same subtype), even when the bounds could be proven to be the + same, as it is just too complex to get right and these rules are intended to be + conservative. End AARM Discussion. - -For the purpose of evaluating these rules, if N denotes a visible renaming of name R, -R shall be used in the rules instead of N. - AARM Reason: This exposes known renamings of slices, indexing, and the like to this - definition. In particular, if we have - C : Character renames S(1); - then C and S(1) are known to denote the same object, as S(1) would replace C when - evaluating the rules. - -Two names N1 and N2 are *known to refer to the same object* if N1 and N2 -are known to denote the same object, or if N1 is known to denote a -subcomponent of the object denoted by N2, or vice-versa. +Two names are *known to refer to the same object* if the names +are known to denote the same object, or if one of the two names is known to +denote a subcomponent or slice of the object denoted by the others. AARM Reason: This ensures that names Prefix.Comp and Prefix are known to refer to the same object for the purposes of the @@ -445,48 +465,40 @@ by copy or by reference. @dinss @s8<@i<Legality Rules>> + +Two @fa<name>s are @i<known to denote the same object> if: -Two @fa<name>s or @fa<prefix>es, @i<N1> and @i<N2>, are @i<known to denote the -same object> if: +@xbullet<both @fa<name>s statically denote the same stand-alone object +or parameter; or> -@xbullet<@i<N1> statically denotes a part of a stand-alone object or parameter, and -@i<N2> statically denotes the same part of the same stand-alone object or -parameter; or> - -@xbullet<@i<N1> is a @fa<selected_component> @i<P1.C1> that represents a -component, @i<N2> is a @fa<selected_component> @i<P2.C2> that represents a -component, @fa<prefix>es @i<P1> and @i<P2> are known to denote the same object, -and selectors @i<C1> and @i<C2> are the same; or> - -@xbullet<@i<N1> is a dereference (implicit or explicit) of @i<P1>, @i<N2> is a -dereference (implicit or explicit) of @i<P2>, and @fa<prefix>es @i<P1> and -@i<P2> are known to denote the same object; or> - -@xbullet<@i<N1> is an @fa<indexed_component> @i<P1>(@i<I1>,...), @i<N2> is an -@fa<indexed_component> @i<P2>(@i<I2>,...), the @fa<prefix> @i<P1> is known to -denote the same object as the @fa<prefix> @i<P2>, and for each index of the -@fa<indexed_component>, @i<I1> and @i<I2> are static expressions with the same -value, or @i<I1> and @i<I2> are names that are known to denote the same object; -or> - -@xbullet<@i<N1> and @i<N2> are @fa<slice>s, their @fa<prefix>es are known to denote -the same object, and the two @fa<slice>s have statically matching index constraints; -or> - -@xbullet<@i<N2> is a @fa<slice> whose @fa<prefix> is known to denote the same object as -@i<N1>, and the index constraint of @i<N2> statically matches the constraint -@i<N1>'First .. @i<N1>'Last; or> - -@xbullet<@i<N1> is a @fa<slice> whose @fa<prefix> is known to denote the same object as -@i<N2>, and the index constraint of @i<N1> statically matches the constraint -@i<N2>'First .. @i<N2>'Last.> - -For the purpose of evaluating these rules, if @i<N> denotes a visible renaming -of name @i<R>, @i<R> shall be used in the rules instead of @i<N>. - -Two @fa<name>s @i<N1> and @i<N2> are @i<known to refer to the same object> if -@i<N1> and @i<N2> are known to denote the same object, or if @i<N1> is known to -denote a subcomponent of the object denoted by @i<N2>, or vice-versa. +@xbullet<both @fa<name>s are @fa<selected_component>s, their @fa<prefix>es are +known to denote the same object, and their @fa<selector_name>s denote the +same component; or> + +@xbullet<both @fa<name>s are dereferences (implicit or explicit), the +dereferenced @fa<name>s are known to denote the same object, +and both @fa<name>s have the same immediately enclosing statement or +declaration; or> + +@xbullet<both @fa<name>s are @fa<indexed_component>s, their @fa<prefix>es are +known to denote the same object, and each of the pairs of corresponding +index values are either static expressions with the same value +or @fa<name>s that are known to denote the same object; or> + +@xbullet<both @fa<name>s are @fa<slice>s, their @fa<prefix>es are known to +denote the same object, and the two @fa<slice>s have statically matching +index constraints; or + +@xbullet<one of the two @fa<name>s statically denotes a renaming declaration +whose renamed @i<object_>@fa<name> is known to denote the same object +as the other @fa<name>; or + +@xbullet<both @fa<name>s are known to denote the same object as a third +@fa<name>.> + +Two @fa<name>s are @i<known to refer to the same object> if the @fa<name>s +are known to denote the same object, or if one of the two @fa<name>s is known to +denote a subcomponent or slice of the object denoted by the others. If a call @i<C> has two or more parameters of mode @b<in out> or @b<out> that are of an elementary type, then the call is legal only if:

Questions? Ask the ACAA Technical Agent