]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Warn on import of parent package
authorBob Duff <duff@adacore.com>
Fri, 10 Dec 2021 19:04:59 +0000 (14:04 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 7 Jan 2022 16:24:05 +0000 (16:24 +0000)
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.

24 files changed:
gcc/ada/fname-sf.adb
gcc/ada/libgnarl/s-stusta.adb
gcc/ada/libgnarl/s-tasdeb.ads
gcc/ada/libgnat/a-calfor.adb
gcc/ada/libgnat/a-tiboio.adb
gcc/ada/libgnat/a-wwboio.adb
gcc/ada/libgnat/a-zzboio.adb
gcc/ada/libgnat/i-cobol.adb
gcc/ada/libgnat/s-bitops.adb
gcc/ada/libgnat/s-bitops.ads
gcc/ada/libgnat/s-direio.adb
gcc/ada/libgnat/s-dwalin.adb
gcc/ada/libgnat/s-geveop.adb
gcc/ada/libgnat/s-mmosin__unix.adb
gcc/ada/libgnat/s-os_lib.adb
gcc/ada/libgnat/s-os_lib.ads
gcc/ada/libgnat/s-pooglo.ads
gcc/ada/libgnat/s-secsta.adb
gcc/ada/libgnat/s-shasto.adb
gcc/ada/libgnat/s-stausa.ads
gcc/ada/libgnat/s-stratt.ads
gcc/ada/libgnat/s-ststop.adb
gcc/ada/sem_ch10.adb
gcc/ada/sinfo.ads

index 8feb150a3de8387a921aaaf28ceeefa451383f2a..eb9f22e870ce60809299aa8271e795309fbec8a6 100644 (file)
@@ -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;
index 959930bda8cf63c6334ac391cd29f980c3b3078e..9b97ea7dfce2fa00b3a710ebdea90de65ee9e82b 100644 (file)
@@ -29,8 +29,6 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System.Stack_Usage;
-
 --  This is why this package is part of GNARL:
 
 with System.Tasking.Debug;
index 8d75a5e0337c73a9c88a2eaa6a825c9939b7f4d8..1574dd1c90b2b6c8c45a8916af152908c233aed5 100644 (file)
@@ -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
index cb6c179ad69ef66f4fb3b694dda43072bb62b9b0..2f2b3741fa4a8359647871ea1940e720e0bf2ffe 100644 (file)
@@ -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
index 340199c98709a0081c91cacc0ed4b0140729d2df..31cb7f267878647891241e48b9026f1b4fec5d55 100644 (file)
@@ -29,7 +29,6 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with Ada.Text_IO; use Ada.Text_IO;
 with Ada.Unchecked_Deallocation;
 
 package body Ada.Text_IO.Bounded_IO is
index a5c85a1f88b06d44403b6a3a975d255ee29f8ec7..7c26981feff1707eeddfc5f1cc964beb659ce22a 100644 (file)
@@ -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
index 8cdc0275fb090856ea91a6598e17d2f9281d23bb..42c6563783b201c29aa07b51ce50c4d8d579c25d 100644 (file)
@@ -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
index b4b62eee485d46743a67122fc7b7318659228d27..d4462f2efa55b9361e97191c3fac9d3d2beea183 100644 (file)
@@ -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
index 392b3459c77727b43d25502b25fb7d1ed38392a9..deea7e8c5f64eff4091175497cf10542d7b79578 100644 (file)
@@ -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;
index baac10d10a99f93db90126a45d1efdb55b26e748..7d3e9c0097f70f4437a6376cf9c6103ebe827fbe 100644 (file)
@@ -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
index 8e3740c47e138c6a34c6e921b7ac9f4ff8e14364..c7022017ef3d0886956c672d5d1f7dd5eacae459 100644 (file)
@@ -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;
index e02b0fdeb2c94523a05fe9d262dfda76a6cb84e1..6be18856d9a9db146c3a224d5bbc5ca94f6ed461 100644 (file)
@@ -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;
index bfbb232a8b1805310639d7e55bb661ac010107c9..b878157730501910b06f14ad8092d61ecf4c73a3 100644 (file)
@@ -29,7 +29,6 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System;                    use System;
 with System.Address_Operations; use System.Address_Operations;
 with System.Storage_Elements;   use System.Storage_Elements;
 
index 6a3e4ce9622b528c39fb93d2515ee3541654b452..2774d75f7cfd8749eeaee383595cf5c1b27dd750 100644 (file)
@@ -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;
index 7df06c4b9eaa06604ffc59facc093e667b1fb027..e3f6b12fe232fdb4385c765a5ec9cb79be39e984 100644 (file)
@@ -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;
index 220a25d57d59bd050ec86267d829b2198d6ed078..6eb788d3487e72aed0e5c4d1e80f6189194ad0d8 100644 (file)
@@ -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
index 67518c280eb0e84948a3e098454ed4ca1db4b6ce..891cd11ddd388dc5d71be4379a030501d782805e 100644 (file)
@@ -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;
 
index e55289f20367ed927ea1285665a340fd7523e672..68af0c72ccce19497acbfd6506e39d6e24896f0b 100644 (file)
@@ -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;
index a1f5a95e81e9f1c4b6b3554eba9a85d503ddfd84..0a6dc87cf689774eefc3d7f828281fb2401a7861 100644 (file)
@@ -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;
index 2d7feeea53dca62b1babaa424ea6278b3068f018..3c272137cd8d4ec8d16ff1f1fe4b6940cf7a9943 100644 (file)
@@ -29,7 +29,6 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with System;
 with System.Storage_Elements;
 with System.Address_To_Access_Conversions;
 with Interfaces;
index 9e6d00116b76f4edd32f805509987d094aa534a0..4af0df93ead87e93fc6a9fc6abf35655d6fe7706 100644 (file)
@@ -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;
 
index d90f391b4f0cc2438fb18ffd7593da663251377f..9a67e1b4bb3c578a2cd614d4357efa957f8a3c59 100644 (file)
@@ -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;
 
index f4ce099884b74aa00cd197994ac60c6ca85d3af2..4e4f83de7921222e245681240e7df6b4175353c1 100644 (file)
@@ -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;
index e96227462ba3445920339c6077c4b86f76a2614d..84980e774c5bf88eaa8805b542c69447472f39a4 100644 (file)
@@ -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.