From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id 6EB293858D28; Fri, 7 Jan 2022 16:26:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6EB293858D28 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-6344] [Ada] Warn on import of parent package X-Act-Checkin: gcc X-Git-Author: Bob Duff X-Git-Refname: refs/heads/master X-Git-Oldrev: 9ceb18d4a28e416cd5d85cbc66427258fcfa9180 X-Git-Newrev: 0c65ca0625b426863ecd294eb9945513a6d057bc Message-Id: <20220107162653.6EB293858D28@sourceware.org> Date: Fri, 7 Jan 2022 16:26:53 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jan 2022 16:26:53 -0000 https://gcc.gnu.org/g:0c65ca0625b426863ecd294eb9945513a6d057bc commit r12-6344-g0c65ca0625b426863ecd294eb9945513a6d057bc Author: Bob Duff Date: Fri Dec 10 14:04:59 2021 -0500 [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. Diff: --- gcc/ada/fname-sf.adb | 1 - gcc/ada/libgnarl/s-stusta.adb | 2 -- gcc/ada/libgnarl/s-tasdeb.ads | 1 - gcc/ada/libgnat/a-calfor.adb | 1 - gcc/ada/libgnat/a-tiboio.adb | 1 - gcc/ada/libgnat/a-wwboio.adb | 1 - gcc/ada/libgnat/a-zzboio.adb | 1 - gcc/ada/libgnat/i-cobol.adb | 3 +-- gcc/ada/libgnat/s-bitops.adb | 3 +-- gcc/ada/libgnat/s-bitops.ads | 2 -- gcc/ada/libgnat/s-direio.adb | 1 - gcc/ada/libgnat/s-dwalin.adb | 1 - gcc/ada/libgnat/s-geveop.adb | 1 - gcc/ada/libgnat/s-mmosin__unix.adb | 1 - gcc/ada/libgnat/s-os_lib.adb | 1 - gcc/ada/libgnat/s-os_lib.ads | 1 - gcc/ada/libgnat/s-pooglo.ads | 1 - gcc/ada/libgnat/s-secsta.adb | 1 - gcc/ada/libgnat/s-shasto.adb | 1 - gcc/ada/libgnat/s-stausa.ads | 1 - gcc/ada/libgnat/s-stratt.ads | 1 - gcc/ada/libgnat/s-ststop.adb | 1 - gcc/ada/sem_ch10.adb | 10 +++++++++- 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 8feb150a3de..eb9f22e870c 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 959930bda8c..9b97ea7dfce 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 8d75a5e0337..1574dd1c90b 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 cb6c179ad69..2f2b3741fa4 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 340199c9870..31cb7f26787 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 a5c85a1f88b..7c26981feff 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 8cdc0275fb0..42c6563783b 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 b4b62eee485..d4462f2efa5 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 392b3459c77..deea7e8c5f6 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 baac10d10a9..7d3e9c0097f 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 8e3740c47e1..c7022017ef3 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 e02b0fdeb2c..6be18856d9a 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 bfbb232a8b1..b8781577305 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 6a3e4ce9622..2774d75f7cf 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 7df06c4b9ea..e3f6b12fe23 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 220a25d57d5..6eb788d3487 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 67518c280eb..891cd11ddd3 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 e55289f2036..68af0c72ccc 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 a1f5a95e81e..0a6dc87cf68 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 2d7feeea53d..3c272137cd8 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 9e6d00116b7..4af0df93ead 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 d90f391b4f0..9a67e1b4bb3 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 f4ce099884b..4e4f83de792 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 e96227462ba..84980e774c5 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.