+2009-04-17 Thomas Quinot <quinot@adacore.com>
+
+ * exp_aggr.adb: Minor code reorganization, no behaviour change.
+
+2009-04-17 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch8.adb (Use_One_Type): Handle properly a redundant use type
+ clause in a unit that is a package body or a subunit, when the previous
+ clause appears in a spec or a parent.
+
2009-04-17 Thomas Quinot <quinot@adacore.com>
* sinfo.ads, exp_aggr.adb, exp_aggr.ads: Minor reformatting
if Present (Comp_Type)
and then Needs_Finalization (Comp_Type)
and then not Is_Limited_Type (Comp_Type)
- and then
- (not Is_Array_Type (Comp_Type)
- or else not Is_Controlled (Component_Type (Comp_Type))
- or else Nkind (Expr) /= N_Aggregate)
+ and then not
+ (Is_Array_Type (Comp_Type)
+ and then Is_Controlled (Component_Type (Comp_Type))
+ and then Nkind (Expr) = N_Aggregate)
then
Append_List_To (L,
Make_Adjust_Call (
Unit1 := Unit (Parent (Clause1));
Unit2 := Unit (Parent (Clause2));
- -- If both clauses are on same unit, report redundancy
+ -- If both clauses are on same unit, or one is the body
+ -- of the other, or one of them is in a subunit, report
+ -- redundancy on the later one.
if Unit1 = Unit2 then
Error_Msg_Sloc := Sloc (Current_Use_Clause (T));
("& is already use-visible through previous "
& "use_type_clause #?", Clause1, T);
return;
+
+ elsif Nkind (Unit1) = N_Subunit then
+ Error_Msg_Sloc := Sloc (Current_Use_Clause (T));
+ Error_Msg_NE
+ ("& is already use-visible through previous "
+ & "use_type_clause #?", Clause1, T);
+ return;
+
+ elsif Nkind_In (Unit2, N_Package_Body, N_Subprogram_Body)
+ and then Nkind (Unit1) /= Nkind (Unit2)
+ and then Nkind (Unit1) /= N_Subunit
+ then
+ Error_Msg_Sloc := Sloc (Clause1);
+ Error_Msg_NE
+ ("& is already use-visible through previous "
+ & "use_type_clause #?", Current_Use_Clause (T), T);
+ return;
end if;
-- There is a redundant use type clause in a child unit.