+2019-08-19 Bob Duff <duff@adacore.com>
+
+ * sem_warn.adb (Warn_On_Unreferenced_Entity): Suppress warning
+ on formal parameters of dispatching operations.
+
2019-08-19 Ed Schonberg <schonberg@adacore.com>
* sem_res.adb (Resolve_Call): A call to an expression function
E := Body_E;
end if;
- if not Is_Trivial_Subprogram (Scope (E)) then
- Error_Msg_NE -- CODEFIX
- ("?u?formal parameter & is not referenced!",
- E, Spec_E);
- end if;
+ declare
+ B : constant Node_Id := Parent (Parent (Scope (E)));
+ S : Entity_Id := Empty;
+ begin
+ if Nkind_In (B,
+ N_Expression_Function,
+ N_Subprogram_Body,
+ N_Subprogram_Renaming_Declaration)
+ then
+ S := Corresponding_Spec (B);
+ end if;
+
+ -- Do not warn for dispatching operations, because
+ -- that causes too much noise. Also do not warn for
+ -- trivial subprograms.
+
+ if (not Present (S)
+ or else not Is_Dispatching_Operation (S))
+ and then not Is_Trivial_Subprogram (Scope (E))
+ then
+ Error_Msg_NE -- CODEFIX
+ ("?u?formal parameter & is not referenced!",
+ E, Spec_E);
+ end if;
+ end;
end if;
end if;
+2019-08-19 Bob Duff <duff@adacore.com>
+
+ * gnat.dg/warn29.adb, gnat.dg/warn29.ads: New testcase.
+
2019-08-19 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/expr_func9.adb: New testcase.
--- /dev/null
+-- { dg-do compile }
+-- { dg-options "-gnatwa" }
+
+with Text_IO; use Text_IO;
+
+package body Warn29 is
+ procedure P (X : T; Y : Integer) is
+ begin
+ Put_Line ("hello");
+ end P;
+end Warn29;