aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2019-08-19 08:37:23 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-08-19 08:37:23 +0000
commitbfa6962fc25e2e24b3a5299095e933f9b57bb6e0 (patch)
treee3a0a408bda5ba809d8c1f2321ab06b27d02e2aa /gcc/ada
parentfcef060c9b321edcb24a56616588e712c22029ba (diff)
downloadgcc-bfa6962fc25e2e24b3a5299095e933f9b57bb6e0.zip
gcc-bfa6962fc25e2e24b3a5299095e933f9b57bb6e0.tar.gz
gcc-bfa6962fc25e2e24b3a5299095e933f9b57bb6e0.tar.bz2
[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
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/sem_warn.adb30
2 files changed, 30 insertions, 5 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 1f490b3..84c2239 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index ca6515c..8f85057 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -4407,11 +4407,31 @@ package body Sem_Warn is
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;