aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-08-28 08:20:44 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-23 04:24:50 -0400
commit0e3ccc6a04100b9998920e82381bf566fc654b8d (patch)
tree80f0a8d46a991f0a42bcb9d11a7b5d611a7097fc /gcc/ada
parentc875250d42d16abb1c638a1b340ea5dac5c9a479 (diff)
downloadgcc-0e3ccc6a04100b9998920e82381bf566fc654b8d.zip
gcc-0e3ccc6a04100b9998920e82381bf566fc654b8d.tar.gz
gcc-0e3ccc6a04100b9998920e82381bf566fc654b8d.tar.bz2
[Ada] Missing detection of unused with_clause
gcc/ada/ * sem_ch4.adb (Complete_Object_Operation): Only mark entities referenced if we are compiling the extended main unit. * sem_attr.adb (Analyze_Attribute [Attribute_Tag]): Record a reference on the type and its scope.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/sem_attr.adb9
-rw-r--r--gcc/ada/sem_ch4.adb24
2 files changed, 23 insertions, 10 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index c80cc06..7a488a7 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -6288,6 +6288,15 @@ package body Sem_Attr is
if Comes_From_Source (N) then
Check_Not_Incomplete_Type;
+
+ -- 'Tag requires visibility on the corresponding package holding
+ -- the tag, so record a reference here, to avoid spurious unused
+ -- with_clause reported when compiling the main unit.
+
+ if In_Extended_Main_Source_Unit (Current_Scope) then
+ Set_Referenced (P_Type, True);
+ Set_Referenced (Scope (P_Type), True);
+ end if;
end if;
-- Set appropriate type
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 61c7b4c..8d74338 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -9010,16 +9010,20 @@ package body Sem_Ch4 is
Rewrite (First_Actual, Obj);
end if;
- -- The operation is obtained from the dispatch table and not by
- -- visibility, and may be declared in a unit that is not explicitly
- -- referenced in the source, but is nevertheless required in the
- -- context of the current unit. Indicate that operation and its scope
- -- are referenced, to prevent spurious and misleading warnings. If
- -- the operation is overloaded, all primitives are in the same scope
- -- and we can use any of them.
-
- Set_Referenced (Entity (Subprog), True);
- Set_Referenced (Scope (Entity (Subprog)), True);
+ if In_Extended_Main_Source_Unit (Current_Scope) then
+ -- The operation is obtained from the dispatch table and not by
+ -- visibility, and may be declared in a unit that is not
+ -- explicitly referenced in the source, but is nevertheless
+ -- required in the context of the current unit. Indicate that
+ -- operation and its scope are referenced, to prevent spurious and
+ -- misleading warnings. If the operation is overloaded, all
+ -- primitives are in the same scope and we can use any of them.
+ -- Don't do that outside the main unit since otherwise this will
+ -- e.g. prevent the detection of some unused with clauses.
+
+ Set_Referenced (Entity (Subprog), True);
+ Set_Referenced (Scope (Entity (Subprog)), True);
+ end if;
Rewrite (Node_To_Replace, Call_Node);