[Ada] Suppress warnings on unreferenced parameters of dispatching ops
If the -gnatwf switch is used to activate warnings on unreferenced formal parameters, the warning is no longer given if the subprogram is dispatching, because such warnings tend to be noise. It is quite common to have a parameter that is necessary just because the subprogram is overriding, or just because we need a controlling parameter for the dispatch. 2019-08-19 Bob Duff <duff@adacore.com> gcc/ada/ * sem_warn.adb (Warn_On_Unreferenced_Entity): Suppress warning on formal parameters of dispatching operations. gcc/testsuite/ * gnat.dg/warn29.adb, gnat.dg/warn29.ads: New testcase. From-SVN: r274663
This commit is contained in:
parent
fcef060c9b
commit
bfa6962fc2
|
@ -1,3 +1,8 @@
|
|||
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
|
||||
|
|
|
@ -4407,11 +4407,31 @@ package body Sem_Warn is
|
|||
E := Body_E;
|
||||
end if;
|
||||
|
||||
if not Is_Trivial_Subprogram (Scope (E)) then
|
||||
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;
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
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.
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
-- { 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;
|
|
@ -0,0 +1,4 @@
|
|||
package Warn29 is
|
||||
type T is tagged null record;
|
||||
procedure P (X : T; Y : Integer);
|
||||
end Warn29;
|
Loading…
Reference in New Issue