diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2022-06-21 10:17:57 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-07-12 12:24:12 +0000 |
commit | a8d17a88a52d2f773423adb55399d23ed5ea03c8 (patch) | |
tree | fed1c2e45aaac773f78b64dc10bec2c7ce87e4bc /gcc/ada | |
parent | a54ad45a63182bf6d1873ed55d641769638e4c8f (diff) | |
download | gcc-a8d17a88a52d2f773423adb55399d23ed5ea03c8.zip gcc-a8d17a88a52d2f773423adb55399d23ed5ea03c8.tar.gz gcc-a8d17a88a52d2f773423adb55399d23ed5ea03c8.tar.bz2 |
[Ada] Warn on unset objects in packages with no bodies
Fix an inconsistency, where GNAT was warning about references to unset
objects inside generic packages with no bodies but not inside ordinary
packages with no bodies.
gcc/ada/
* sem_ch7.adb (Analyze_Package_Declaration): Check references to
unset objects.
gcc/testsuite/
* gnat.dg/specs/discr5.ads: Expect new warnings.
* gnat.dg/specs/empty_variants.ads: Likewise.
* gnat.dg/specs/pack13.ads: Likewise.
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/sem_ch7.adb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb index 31c04ad..5c347bd 100644 --- a/gcc/ada/sem_ch7.adb +++ b/gcc/ada/sem_ch7.adb @@ -1253,6 +1253,13 @@ package body Sem_Ch7 is (Context => N, Is_Main_Unit => Parent (N) = Cunit (Main_Unit)); end if; + + -- Warn about references to unset objects, which is straightforward + -- for packages with no bodies. For packages with bodies this is more + -- complicated, because some of the objects might be set between spec + -- and body elaboration, in nested or child packages, etc. + + Check_References (Id); end if; -- Set Body_Required indication on the compilation unit node |