When an indexed reference to a packed array is expanded, it is rewritten as
a boolean operation on the prefix that denotes the packed array. If the prefix
is a function call it must not be reanalyzed, because it will have been expanded
already. and may carry extra actuals for accessibility checks.
No simple example available.
Tested on x86_64-pc-linux-gnu, committed on trunk
2011-08-31 Ed Schonberg <[email protected]>
* exp_pakd.adb (Convert_To_PAT_Type): If prefix is a function call, do
not reanalyze it.
Index: exp_pakd.adb
===================================================================
--- exp_pakd.adb (revision 178358)
+++ exp_pakd.adb (working copy)
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -702,7 +702,9 @@
-- see Reset_Packed_Prefix. On the other hand, if the prefix is a simple
-- array reference, reanalysis can produce spurious type errors when the
-- PAT type is replaced again with the original type of the array. Same
- -- for the case of a dereference. The following is correct and minimal,
+ -- for the case of a dereference. Ditto for function calls: expansion
+ -- may introduce additional actuals which will trigger errors if call
+ -- is reanalyzed. The following is correct and minimal,
-- but the handling of more complex packed expressions in actuals is
-- confused. Probably the problem only remains for actuals in calls.
@@ -713,6 +715,7 @@
(Nkind (Aexp) = N_Indexed_Component
and then Is_Entity_Name (Prefix (Aexp)))
or else Nkind (Aexp) = N_Explicit_Dereference
+ or else Nkind (Aexp) = N_Function_Call
then
Set_Analyzed (Aexp);
end if;