Before this patch, warnings handled by `Sem_Warn.Check_References` were
erroneously emitted in some cases. Here is an example of a program that,
when compiled with the `-gnatwu` switch, triggered the bug:
procedure Main is
package T is
A : Integer;
end T;
begin
T.A := 7;
end Main;
The following message was emitted:
main.adb:3:07: warning: variable "A" is never read and never assigned [-gnatwu]
This patch mitigates the issue by restricting the cases in which
`Sem_Warn.Check_References` is called for package specifications.
Note that the recursive calls in `Sem_Warn.Check_References` can be used
to convince oneself that this patch does not remove legitimate warnings
for non-library-level package specifications.
gcc/ada/
* sem_ch7.adb (Analyze_Package_Declaration): Restrict calls to
`Sem_Warn.Check_References` and adjust comment accordingly.