"Sam" == Samuel Tardieu <sam@rfc1149.net> writes:
Sam> Here is an updated proposed patch:
It doesn't still cover all the cases (since the requirement for
the prefix to denote an object is no longer present). For example, we
still get an ICE on this one:
procedure T is
X : Integer := 3;
function F (A : Integer) return Integer is
begin
return A;
end F;
begin
pragma Assert (X = F(3)'Old);
null;
end T;
Inserting the 'Old computation at the end of the subprogram
declarations instead of at the beginning is not a solution, as some
declarations could make function calls which would modify the value
being captures, such as:
procedure T (X : in out Integer) is
Y : Integer := Increment_And_Return (X);
begin
pragma Assert (Y = X'Old + 1);
null;
end T;
in which case the incorrect X'Old value would be computed.
To properly catch all the cases, 'Old should be analyzed in the same
scope as the subprogram default expression augmented with the
subprogram formal parameters. Or its prefix should be restricted to
some simple forms such as a variable or a parameterless function call.
Note that using an arbitrary expression is actually impossible with
the current code:
8. pragma Assert (X = (X)'Old);
|
>>> binary operator expected