+2019-07-22 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_res.adb (Resolve_Selected_Component): If the prefix has a
+ deferred reference, generate the correct reference now, to
+ indicate that the previous assignment is used. This prevents
+ spurious warnings on useless assignments when compiling with all
+ warnings enabled. when there is a subsequent call in the same
+ stqtement list, in which the prefix of the selected component is
+ the actual for an out parameter.
+
2019-07-22 Eric Botcazou <ebotcazou@adacore.com>
* exp_attr.adb (Expand_Loop_Entry_Attribute): Copy the condition
if Is_Access_Type (Etype (P)) then
T := Designated_Type (Etype (P));
Check_Fully_Declared_Prefix (T, P);
+
else
T := Etype (P);
+
+ -- If the prefix is an entity it may have a deferred reference set
+ -- during analysis of the selected component. After resolution we
+ -- can transform it into a proper reference. This prevents spurious
+ -- warnings on useless assignments when the same selected component
+ -- is the actual for an out parameter in a subsequent call.
+
+ if Is_Entity_Name (P)
+ and then Has_Deferred_Reference (Entity (P))
+ then
+ if May_Be_Lvalue (N) then
+ Generate_Reference (Entity (P), P, 'm');
+ else
+ Generate_Reference (Entity (P), P, 'r');
+ end if;
+ end if;
end if;
-- Set flag for expander if discriminant check required on a component
+2019-07-22 Ed Schonberg <schonberg@adacore.com>
+
+ * gnat.dg/warn22.adb: New testcase.
+
2019-07-22 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/loop_invariant1.adb, gnat.dg/loop_invariant1.ads: New
--- /dev/null
+-- { dg-do compile }
+-- { dg-options "-gnatwa" }
+
+with Ada.Text_IO;
+
+procedure Warn22
+is
+ type X is
+ record
+ Str : String (1 .. 3);
+ end record;
+
+ type T is
+ record
+ Value : X;
+ end record;
+
+ procedure Consume_Data (Item : out T) is
+ begin
+ Item := (Value => (Str => "Bar"));
+ end Consume_Data;
+
+ Baz : T;
+begin
+
+ Baz := (Value => (Str => "Foo"));
+
+ Ada.Text_IO.Put_Line (Baz.Value.Str);
+
+ Consume_Data (Baz);
+
+ Ada.Text_IO.Put_Line (Baz.Value.Str);
+
+end Warn22;