This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PING^2] ada: Add limitations on the acceptable prefixes of 'Old


Samuel Tardieu wrote:
"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

This of course is illegal, (X) is not a name, so it is just a syntactic error, arbitrary expressions are definitely NOT allowed.

Will look at rest of issues later ...

Any idea on how to make this both robust and easy to understand?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]