Patchwork [Ada] Expansion of indexed referenced to packed arrays when prefix is a call

login
register
mail settings
Submitter Arnaud Charlet
Date Aug. 31, 2011, 9:33 a.m.
Message ID <20110831093358.GA19933@adacore.com>
Download mbox | patch
Permalink /patch/112487/
State New
Headers show

Comments

Arnaud Charlet - Aug. 31, 2011, 9:33 a.m.
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  <schonberg@adacore.com>

	* exp_pakd.adb (Convert_To_PAT_Type): If prefix is a function call, do
	not reanalyze it.

Patch

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;