2004-10-04 Robert Dewar <dewar@gnat.com>
+ * exp_ch4.adb (Is_Procedure_Actual): Correct so that this does not
+ consider expressions buried within a procedure actual to be an actual.
+ This caused some blowups with uses of packed slices within a procedure
+ actual.
+
+2004-10-04 Robert Dewar <dewar@gnat.com>
+
* exp_ch3.adb (Needs_Simple_Initialization): Modular packed arrays no
longer need to be initialized to zero.
(Get_Simple_Init_Val): Modular packed arrays no longer need to be
Ptp : Entity_Id := Etype (Pfx);
function Is_Procedure_Actual (N : Node_Id) return Boolean;
- -- Check whether context is a procedure call, in which case
- -- expansion of a bit-packed slice is deferred until the call
- -- itself is expanded.
+ -- Check whether the argument is an actual for a procedure call,
+ -- in which case the expansion of a bit-packed slice is deferred
+ -- until the call itself is expanded. The reason this is required
+ -- is that we might have an IN OUT or OUT parameter, and the copy out
+ -- is essential, and that copy out would be missed if we created a
+ -- temporary here in Expand_N_Slice. Note that we don't bother
+ -- to test specifically for an IN OUT or OUT mode parameter, since it
+ -- is a bit tricky to do, and it is harmless to defer expansion
+ -- in the IN case, since the call processing will still generate the
+ -- appropriate copy in operation, which will take care of the slice.
procedure Make_Temporary;
-- Create a named variable for the value of the slice, in
Par : Node_Id := Parent (N);
begin
- while Present (Par)
- and then Nkind (Par) not in N_Statement_Other_Than_Procedure_Call
loop
+ -- If our parent is a procedure call we can return
+
if Nkind (Par) = N_Procedure_Call_Statement then
return True;
- elsif Nkind (Par) = N_Function_Call then
- return False;
+ -- If our parent is a type conversion, keep climbing the
+ -- tree, since a type conversion can be a procedure actual.
+ -- Also keep climbing if parameter association or a qualified
+ -- expression, since these are additional cases that do can
+ -- appear on procedure actuals.
- else
+ elsif Nkind (Par) = N_Type_Conversion
+ or else Nkind (Par) = N_Parameter_Association
+ or else Nkind (Par) = N_Qualified_Expression
+ then
Par := Parent (Par);
+
+ -- Any other case is not what we are looking for
+
+ else
+ return False;
end if;
end loop;
-
- return False;
end Is_Procedure_Actual;
--------------------