diff options
author | Bob Duff <duff@adacore.com> | 2021-12-10 14:04:59 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-01-07 16:24:05 +0000 |
commit | 0c65ca0625b426863ecd294eb9945513a6d057bc (patch) | |
tree | c086be2696cfd871c59bff87f8a00856f9b7f447 | |
parent | 9ceb18d4a28e416cd5d85cbc66427258fcfa9180 (diff) | |
download | gcc-0c65ca0625b426863ecd294eb9945513a6d057bc.zip gcc-0c65ca0625b426863ecd294eb9945513a6d057bc.tar.gz gcc-0c65ca0625b426863ecd294eb9945513a6d057bc.tar.bz2 |
[Ada] Warn on import of parent package
gcc/ada/
* sem_ch10.adb (Check_Redundant_Withs): Add a warning if a
library unit with's its own ancestor. Note that this warning is
not triggered for something like "with P.R;" in P.Q, because
there the "with P;" is considered implicit.
* fname-sf.adb, libgnarl/s-stusta.adb, libgnarl/s-tasdeb.ads,
libgnat/a-calfor.adb, libgnat/a-tiboio.adb,
libgnat/a-wwboio.adb, libgnat/a-zzboio.adb, libgnat/i-cobol.adb,
libgnat/s-bitops.adb, libgnat/s-bitops.ads,
libgnat/s-direio.adb, libgnat/s-dwalin.adb,
libgnat/s-geveop.adb, libgnat/s-mmosin__unix.adb,
libgnat/s-os_lib.adb, libgnat/s-os_lib.ads,
libgnat/s-pooglo.ads, libgnat/s-secsta.adb,
libgnat/s-shasto.adb, libgnat/s-stausa.ads,
libgnat/s-stratt.ads, libgnat/s-ststop.adb: Remove with of
parent.
* sinfo.ads: Minor comment fix.
-rw-r--r-- | gcc/ada/fname-sf.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnarl/s-stusta.adb | 2 | ||||
-rw-r--r-- | gcc/ada/libgnarl/s-tasdeb.ads | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/a-calfor.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/a-tiboio.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/a-wwboio.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/a-zzboio.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/i-cobol.adb | 3 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-bitops.adb | 3 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-bitops.ads | 2 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-direio.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-dwalin.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-geveop.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-mmosin__unix.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-os_lib.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-os_lib.ads | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-pooglo.ads | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-secsta.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-shasto.adb | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-stausa.ads | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-stratt.ads | 1 | ||||
-rw-r--r-- | gcc/ada/libgnat/s-ststop.adb | 1 | ||||
-rw-r--r-- | gcc/ada/sem_ch10.adb | 10 | ||||
-rw-r--r-- | gcc/ada/sinfo.ads | 2 |
24 files changed, 12 insertions, 28 deletions
diff --git a/gcc/ada/fname-sf.adb b/gcc/ada/fname-sf.adb index 8feb150..eb9f22e 100644 --- a/gcc/ada/fname-sf.adb +++ b/gcc/ada/fname-sf.adb @@ -24,7 +24,6 @@ ------------------------------------------------------------------------------ with Casing; use Casing; -with Fname; use Fname; with Fname.UF; use Fname.UF; with SFN_Scan; use SFN_Scan; with Osint; use Osint; diff --git a/gcc/ada/libgnarl/s-stusta.adb b/gcc/ada/libgnarl/s-stusta.adb index 959930b..9b97ea7 100644 --- a/gcc/ada/libgnarl/s-stusta.adb +++ b/gcc/ada/libgnarl/s-stusta.adb @@ -29,8 +29,6 @@ -- -- ------------------------------------------------------------------------------ -with System.Stack_Usage; - -- This is why this package is part of GNARL: with System.Tasking.Debug; diff --git a/gcc/ada/libgnarl/s-tasdeb.ads b/gcc/ada/libgnarl/s-tasdeb.ads index 8d75a5e..1574dd1 100644 --- a/gcc/ada/libgnarl/s-tasdeb.ads +++ b/gcc/ada/libgnarl/s-tasdeb.ads @@ -32,7 +32,6 @@ -- This package encapsulates all direct interfaces to task debugging services -- that are needed by gdb with gnat mode. -with System.Tasking; with System.OS_Interface; package System.Tasking.Debug is diff --git a/gcc/ada/libgnat/a-calfor.adb b/gcc/ada/libgnat/a-calfor.adb index cb6c179..2f2b374 100644 --- a/gcc/ada/libgnat/a-calfor.adb +++ b/gcc/ada/libgnat/a-calfor.adb @@ -29,7 +29,6 @@ -- -- ------------------------------------------------------------------------------ -with Ada.Calendar; use Ada.Calendar; with Ada.Calendar.Time_Zones; use Ada.Calendar.Time_Zones; package body Ada.Calendar.Formatting is diff --git a/gcc/ada/libgnat/a-tiboio.adb b/gcc/ada/libgnat/a-tiboio.adb index 340199c..31cb7f2 100644 --- a/gcc/ada/libgnat/a-tiboio.adb +++ b/gcc/ada/libgnat/a-tiboio.adb @@ -29,7 +29,6 @@ -- -- ------------------------------------------------------------------------------ -with Ada.Text_IO; use Ada.Text_IO; with Ada.Unchecked_Deallocation; package body Ada.Text_IO.Bounded_IO is diff --git a/gcc/ada/libgnat/a-wwboio.adb b/gcc/ada/libgnat/a-wwboio.adb index a5c85a1..7c26981 100644 --- a/gcc/ada/libgnat/a-wwboio.adb +++ b/gcc/ada/libgnat/a-wwboio.adb @@ -29,7 +29,6 @@ -- -- ------------------------------------------------------------------------------ -with Ada.Wide_Text_IO; use Ada.Wide_Text_IO; with Ada.Unchecked_Deallocation; package body Ada.Wide_Text_IO.Wide_Bounded_IO is diff --git a/gcc/ada/libgnat/a-zzboio.adb b/gcc/ada/libgnat/a-zzboio.adb index 8cdc027..42c6563 100644 --- a/gcc/ada/libgnat/a-zzboio.adb +++ b/gcc/ada/libgnat/a-zzboio.adb @@ -29,7 +29,6 @@ -- -- ------------------------------------------------------------------------------ -with Ada.Wide_Wide_Text_IO; use Ada.Wide_Wide_Text_IO; with Ada.Unchecked_Deallocation; package body Ada.Wide_Wide_Text_IO.Wide_Wide_Bounded_IO is diff --git a/gcc/ada/libgnat/i-cobol.adb b/gcc/ada/libgnat/i-cobol.adb index b4b62ee..d4462f2 100644 --- a/gcc/ada/libgnat/i-cobol.adb +++ b/gcc/ada/libgnat/i-cobol.adb @@ -34,8 +34,7 @@ -- particular COBOL format is completely contained in the private part of -- the spec. -with Interfaces; use Interfaces; -with System; use System; +with System; use System; with Ada.Unchecked_Conversion; package body Interfaces.COBOL is diff --git a/gcc/ada/libgnat/s-bitops.adb b/gcc/ada/libgnat/s-bitops.adb index 392b345..deea7e8 100644 --- a/gcc/ada/libgnat/s-bitops.adb +++ b/gcc/ada/libgnat/s-bitops.adb @@ -29,8 +29,7 @@ -- -- ------------------------------------------------------------------------------ -with System; use System; -with System.Unsigned_Types; use System.Unsigned_Types; +with System.Unsigned_Types; use System.Unsigned_Types; with Ada.Exceptions; use Ada.Exceptions; with Ada.Unchecked_Conversion; diff --git a/gcc/ada/libgnat/s-bitops.ads b/gcc/ada/libgnat/s-bitops.ads index baac10d..7d3e9c0 100644 --- a/gcc/ada/libgnat/s-bitops.ads +++ b/gcc/ada/libgnat/s-bitops.ads @@ -31,8 +31,6 @@ -- Operations on packed bit strings -with System; - package System.Bit_Ops is -- Note: in all the following routines, the System.Address parameters diff --git a/gcc/ada/libgnat/s-direio.adb b/gcc/ada/libgnat/s-direio.adb index 8e3740c..c702201 100644 --- a/gcc/ada/libgnat/s-direio.adb +++ b/gcc/ada/libgnat/s-direio.adb @@ -32,7 +32,6 @@ with Ada.IO_Exceptions; use Ada.IO_Exceptions; with Ada.Unchecked_Deallocation; with Interfaces.C_Streams; use Interfaces.C_Streams; -with System; use System; with System.CRTL; with System.File_IO; with System.Soft_Links; diff --git a/gcc/ada/libgnat/s-dwalin.adb b/gcc/ada/libgnat/s-dwalin.adb index e02b0fd..6be18856d 100644 --- a/gcc/ada/libgnat/s-dwalin.adb +++ b/gcc/ada/libgnat/s-dwalin.adb @@ -35,7 +35,6 @@ with Ada.Unchecked_Deallocation; with Interfaces; use Interfaces; -with System; use System; with System.Address_Image; with System.Bounded_Strings; use System.Bounded_Strings; with System.IO; use System.IO; diff --git a/gcc/ada/libgnat/s-geveop.adb b/gcc/ada/libgnat/s-geveop.adb index bfbb232..b878157 100644 --- a/gcc/ada/libgnat/s-geveop.adb +++ b/gcc/ada/libgnat/s-geveop.adb @@ -29,7 +29,6 @@ -- -- ------------------------------------------------------------------------------ -with System; use System; with System.Address_Operations; use System.Address_Operations; with System.Storage_Elements; use System.Storage_Elements; diff --git a/gcc/ada/libgnat/s-mmosin__unix.adb b/gcc/ada/libgnat/s-mmosin__unix.adb index 6a3e4ce..2774d75 100644 --- a/gcc/ada/libgnat/s-mmosin__unix.adb +++ b/gcc/ada/libgnat/s-mmosin__unix.adb @@ -30,7 +30,6 @@ ------------------------------------------------------------------------------ with Ada.IO_Exceptions; -with System; use System; with System.OS_Lib; use System.OS_Lib; with System.Mmap.Unix; use System.Mmap.Unix; diff --git a/gcc/ada/libgnat/s-os_lib.adb b/gcc/ada/libgnat/s-os_lib.adb index 7df06c4..e3f6b12 100644 --- a/gcc/ada/libgnat/s-os_lib.adb +++ b/gcc/ada/libgnat/s-os_lib.adb @@ -31,7 +31,6 @@ with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; -with System; use System; with System.Case_Util; with System.CRTL; with System.Soft_Links; diff --git a/gcc/ada/libgnat/s-os_lib.ads b/gcc/ada/libgnat/s-os_lib.ads index 220a25d..6eb788d 100644 --- a/gcc/ada/libgnat/s-os_lib.ads +++ b/gcc/ada/libgnat/s-os_lib.ads @@ -48,7 +48,6 @@ -- be used by other predefined packages. User access to this package is via -- a renaming of this package in GNAT.OS_Lib (file g-os_lib.ads). -with System; with System.Strings; package System.OS_Lib is diff --git a/gcc/ada/libgnat/s-pooglo.ads b/gcc/ada/libgnat/s-pooglo.ads index 67518c2..891cd11 100644 --- a/gcc/ada/libgnat/s-pooglo.ads +++ b/gcc/ada/libgnat/s-pooglo.ads @@ -32,7 +32,6 @@ -- Storage pool corresponding to default global storage pool used for types -- for which no storage pool is specified. -with System; with System.Storage_Pools; with System.Storage_Elements; diff --git a/gcc/ada/libgnat/s-secsta.adb b/gcc/ada/libgnat/s-secsta.adb index e55289f..68af0c7 100644 --- a/gcc/ada/libgnat/s-secsta.adb +++ b/gcc/ada/libgnat/s-secsta.adb @@ -32,7 +32,6 @@ with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; -with System; use System; with System.Parameters; use System.Parameters; with System.Soft_Links; use System.Soft_Links; with System.Storage_Elements; use System.Storage_Elements; diff --git a/gcc/ada/libgnat/s-shasto.adb b/gcc/ada/libgnat/s-shasto.adb index a1f5a95..0a6dc87 100644 --- a/gcc/ada/libgnat/s-shasto.adb +++ b/gcc/ada/libgnat/s-shasto.adb @@ -36,7 +36,6 @@ with Ada.Streams.Stream_IO; with System.Global_Locks; with System.Soft_Links; -with System; with System.CRTL; with System.File_Control_Block; with System.File_IO; diff --git a/gcc/ada/libgnat/s-stausa.ads b/gcc/ada/libgnat/s-stausa.ads index 2d7feee..3c27213 100644 --- a/gcc/ada/libgnat/s-stausa.ads +++ b/gcc/ada/libgnat/s-stausa.ads @@ -29,7 +29,6 @@ -- -- ------------------------------------------------------------------------------ -with System; with System.Storage_Elements; with System.Address_To_Access_Conversions; with Interfaces; diff --git a/gcc/ada/libgnat/s-stratt.ads b/gcc/ada/libgnat/s-stratt.ads index 9e6d001..4af0df9 100644 --- a/gcc/ada/libgnat/s-stratt.ads +++ b/gcc/ada/libgnat/s-stratt.ads @@ -37,7 +37,6 @@ -- defined types, the subprogram for the corresponding root type is called -- with an appropriate conversion. -with System; with System.Unsigned_Types; with Ada.Streams; diff --git a/gcc/ada/libgnat/s-ststop.adb b/gcc/ada/libgnat/s-ststop.adb index d90f391..9a67e1b 100644 --- a/gcc/ada/libgnat/s-ststop.adb +++ b/gcc/ada/libgnat/s-ststop.adb @@ -33,7 +33,6 @@ with Ada.IO_Exceptions; use Ada.IO_Exceptions; with Ada.Streams; use Ada.Streams; with Ada.Unchecked_Conversion; -with System; use System; with System.Storage_Elements; use System.Storage_Elements; with System.Stream_Attributes; diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index f4ce099..4e4f83d 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -268,6 +268,8 @@ package body Sem_Ch10 is ------------------------------ procedure Analyze_Compilation_Unit (N : Node_Id) is + Unit_Node : constant Node_Id := Unit (N); + procedure Check_Redundant_Withs (Context_Items : List_Id; Spec_Context_Items : List_Id := No_List); @@ -587,6 +589,13 @@ package body Sem_Ch10 is -- Standalone package spec or body check else + if Is_Ancestor_Package (Entity (Name (Clause)), + Defining_Entity (Unit_Node)) + then + Error_Msg_N + ("unnecessary with of ancestor?r?", Clause); + end if; + declare Dummy : Boolean := False; Withed : Boolean := False; @@ -617,7 +626,6 @@ package body Sem_Ch10 is -- Local variables Main_Cunit : constant Node_Id := Cunit (Main_Unit); - Unit_Node : constant Node_Id := Unit (N); Lib_Unit : Node_Id := Library_Unit (N); Par_Spec_Name : Unit_Name_Type; Spec_Id : Entity_Id; diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index e962274..84980e7 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -200,7 +200,7 @@ package Sinfo is -- The exceptions to this rule occur with {DEFINING_IDENTIFIERS} in all -- contexts, which is handled as described in the previous section, and - -- with {,library_unit_NAME} in the N_With_Clause mode, which is handled + -- with {,library_unit_NAME} in the N_With_Clause node, which is handled -- using the First_Name and Last_Name flags, as further detailed in the -- description of the N_With_Clause node. |