aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-09-15 08:56:31 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-26 04:59:05 -0400
commit7649892bfc838aeb0723200b56f34bebe2a87b46 (patch)
treedd21e3a106e126d28173c0a1d2dff25fcd974ffd
parentf69ecf3bbad025688ec79e0090665774f254b761 (diff)
downloadgcc-7649892bfc838aeb0723200b56f34bebe2a87b46.zip
gcc-7649892bfc838aeb0723200b56f34bebe2a87b46.tar.gz
gcc-7649892bfc838aeb0723200b56f34bebe2a87b46.tar.bz2
[Ada] Suppress warnings on unreferenced parameters of dispatching ops
gcc/ada/ * sem_warn.adb (Warn_On_Unreferenced_Entity): Suppress warning on formal parameters of all dispatching operations. gcc/testsuite/ * gnat.dg/warn14.adb: Update expectations.
-rw-r--r--gcc/ada/sem_warn.adb29
-rw-r--r--gcc/testsuite/gnat.dg/warn14.adb2
2 files changed, 19 insertions, 12 deletions
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index d1acf2f..7289ea7 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -4421,23 +4421,30 @@ package body Sem_Warn is
end if;
declare
- B : constant Node_Id := Parent (Parent (Scope (E)));
- S : Entity_Id := Empty;
+ S : Node_Id := Scope (E);
begin
- if Nkind (B) in
- N_Expression_Function |
- N_Subprogram_Body |
- N_Subprogram_Renaming_Declaration
- then
- S := Corresponding_Spec (B);
+ if Ekind (S) = E_Subprogram_Body then
+ S := Parent (S);
+
+ while Nkind (S) not in
+ N_Expression_Function |
+ N_Subprogram_Body |
+ N_Subprogram_Renaming_Declaration |
+ N_Empty
+ loop
+ S := Parent (S);
+ end loop;
+
+ if Present (S) then
+ S := Corresponding_Spec (S);
+ end if;
end if;
-- Do not warn for dispatching operations, because
-- that causes too much noise. Also do not warn for
- -- trivial subprograms.
+ -- trivial subprograms (e.g. stubs).
- if (not Present (S)
- or else not Is_Dispatching_Operation (S))
+ if (No (S) or else not Is_Dispatching_Operation (S))
and then not Is_Trivial_Subprogram (Scope (E))
then
Error_Msg_NE -- CODEFIX
diff --git a/gcc/testsuite/gnat.dg/warn14.adb b/gcc/testsuite/gnat.dg/warn14.adb
index d7fbece..f9d03d1 100644
--- a/gcc/testsuite/gnat.dg/warn14.adb
+++ b/gcc/testsuite/gnat.dg/warn14.adb
@@ -23,7 +23,7 @@ procedure Warn14 is
package YY is
type XX is tagged null record;
- function F4 (Y : XX; U : Boolean) return Natural is (1); -- { dg-warning "formal parameter \"U\" is not referenced" }
+ function F4 (Y : XX; U : Boolean) return Natural is (1);
end YY;
XXX : YY.XX;