public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Remove obsolete uses of Unchecked_Deallocation from Ada 83
@ 2022-05-13  8:07 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-13  8:07 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

[-- Attachment #1: Type: text/plain, Size: 666 bytes --]

In Ada 83 the Unchecked_Deallocation was a top-level unit; since Ada 95
it is an obsolete renaming of Ada.Unchecked_Deallocation. GNAT doesn't
yet warn about uses of these obsolete renamings, but it still seems
better to avoid them.

Cleanup before adding a new instance of Unchecked_Deallocation.
Offending occurrences found with grep.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* butil.adb, sem.adb, sinput.adb, types.ads, xref_lib.adb:
	Replace uses of Unchecked_Deallocation with
	Ada.Unchecked_Deallocation.
	* doc/gnat_ugn/gnat_and_program_execution.rst: Likewise for the
	documentation; fix casing of GNAT.IO.
	* gnat_ugn.texi: Regenerate.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 8067 bytes --]

diff --git a/gcc/ada/butil.adb b/gcc/ada/butil.adb
--- a/gcc/ada/butil.adb
+++ b/gcc/ada/butil.adb
@@ -23,9 +23,9 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
+with Ada.Unchecked_Deallocation;
 with Opt;    use Opt;
 with Output; use Output;
-with Unchecked_Deallocation;
 
 with GNAT; use GNAT;
 
@@ -540,7 +540,7 @@ package body Butil is
    ---------------------------------
 
    function Read_Forced_Elab_Order_File return String_Ptr is
-      procedure Free is new Unchecked_Deallocation (String, String_Ptr);
+      procedure Free is new Ada.Unchecked_Deallocation (String, String_Ptr);
 
       Descr    : File_Descriptor;
       Len      : Natural;


diff --git a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
--- a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
+++ b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
@@ -3590,9 +3590,9 @@ properly allocated memory location. Here is a complete example of use of
 
   .. code-block:: ada
 
-      with Gnat.Io; use Gnat.Io;
-      with Unchecked_Deallocation;
-      with Unchecked_Conversion;
+      with GNAT.IO; use GNAT.IO;
+      with Ada.Unchecked_Deallocation;
+      with Ada.Unchecked_Conversion;
       with GNAT.Debug_Pools;
       with System.Storage_Elements;
       with Ada.Exceptions; use Ada.Exceptions;
@@ -3604,8 +3604,8 @@ properly allocated memory location. Here is a complete example of use of
          P : GNAT.Debug_Pools.Debug_Pool;
          for T'Storage_Pool use P;
 
-         procedure Free is new Unchecked_Deallocation (Integer, T);
-         function UC is new Unchecked_Conversion (U, T);
+         procedure Free is new Ada.Unchecked_Deallocation (Integer, T);
+         function UC is new Ada.Unchecked_Conversion (U, T);
          A, B : aliased T;
 
          procedure Info is new GNAT.Debug_Pools.Print_Info(Put_Line);
@@ -3864,12 +3864,12 @@ execution of this erroneous program:
 
     .. code-block:: ada
 
-       with Unchecked_Deallocation;
+       with Ada.Unchecked_Deallocation;
        procedure Test_Gm is
 
           type T is array (1..1000) of Integer;
           type Ptr is access T;
-          procedure Free is new Unchecked_Deallocation (T, Ptr);
+          procedure Free is new Ada.Unchecked_Deallocation (T, Ptr);
           A : Ptr;
 
           procedure My_Alloc is


diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -22221,9 +22221,9 @@ properly allocated memory location. Here is a complete example of use of
 @quotation
 
 @example
-with Gnat.Io; use Gnat.Io;
-with Unchecked_Deallocation;
-with Unchecked_Conversion;
+with GNAT.IO; use GNAT.IO;
+with Ada.Unchecked_Deallocation;
+with Ada.Unchecked_Conversion;
 with GNAT.Debug_Pools;
 with System.Storage_Elements;
 with Ada.Exceptions; use Ada.Exceptions;
@@ -22235,8 +22235,8 @@ procedure Debug_Pool_Test is
    P : GNAT.Debug_Pools.Debug_Pool;
    for T'Storage_Pool use P;
 
-   procedure Free is new Unchecked_Deallocation (Integer, T);
-   function UC is new Unchecked_Conversion (U, T);
+   procedure Free is new Ada.Unchecked_Deallocation (Integer, T);
+   function UC is new Ada.Unchecked_Conversion (U, T);
    A, B : aliased T;
 
    procedure Info is new GNAT.Debug_Pools.Print_Info(Put_Line);
@@ -29248,8 +29248,8 @@ to permit their use in free software.
 
 @printindex ge
 
-@anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{                              }
 @anchor{cf}@w{                              }
+@anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{                              }
 
 @c %**end of body
 @bye


diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb
--- a/gcc/ada/sem.adb
+++ b/gcc/ada/sem.adb
@@ -61,7 +61,7 @@ with Stylesw;        use Stylesw;
 with Uintp;          use Uintp;
 with Uname;          use Uname;
 
-with Unchecked_Deallocation;
+with Ada.Unchecked_Deallocation;
 
 pragma Warnings (Off, Sem_Util);
 --  Suppress warnings of unused with for Sem_Util (used only in asserts)
@@ -1062,7 +1062,7 @@ package body Sem is
    procedure Initialize is
       Next : Suppress_Stack_Entry_Ptr;
 
-      procedure Free is new Unchecked_Deallocation
+      procedure Free is new Ada.Unchecked_Deallocation
         (Suppress_Stack_Entry, Suppress_Stack_Entry_Ptr);
 
    begin


diff --git a/gcc/ada/sinput.adb b/gcc/ada/sinput.adb
--- a/gcc/ada/sinput.adb
+++ b/gcc/ada/sinput.adb
@@ -41,8 +41,8 @@ with System.Storage_Elements;
 with System.Memory;
 with System.WCh_Con; use System.WCh_Con;
 
+with Ada.Unchecked_Deallocation;
 with Unchecked_Conversion;
-with Unchecked_Deallocation;
 
 package body Sinput is
 
@@ -319,10 +319,10 @@ package body Sinput is
    -- Clear_Source_File_Table --
    -----------------------------
 
-   procedure Free is new Unchecked_Deallocation
+   procedure Free is new Ada.Unchecked_Deallocation
      (Lines_Table_Type, Lines_Table_Ptr);
 
-   procedure Free is new Unchecked_Deallocation
+   procedure Free is new Ada.Unchecked_Deallocation
      (Logical_Lines_Table_Type, Logical_Lines_Table_Ptr);
 
    procedure Clear_Source_File_Table is
@@ -383,7 +383,7 @@ package body Sinput is
       Temp : Source_Buffer_Ptr_Var := To_Source_Buffer_Ptr_Var (Src);
 
       procedure Free_Ptr is new
-        Unchecked_Deallocation (Source_Buffer, Source_Buffer_Ptr_Var);
+        Ada.Unchecked_Deallocation (Source_Buffer, Source_Buffer_Ptr_Var);
    begin
       Free_Ptr (Temp);
       Src := null;
@@ -922,7 +922,7 @@ package body Sinput is
       pragma Import (Ada, Dope);
       use System.Storage_Elements;
       for Dope'Address use Src + System.Address'Size / 8;
-      procedure Free is new Unchecked_Deallocation (Dope_Rec, Dope_Ptr);
+      procedure Free is new Ada.Unchecked_Deallocation (Dope_Rec, Dope_Ptr);
    begin
       Free (Dope);
    end Free_Dope;


diff --git a/gcc/ada/types.ads b/gcc/ada/types.ads
--- a/gcc/ada/types.ads
+++ b/gcc/ada/types.ads
@@ -39,9 +39,9 @@
 --  2s-complement. If there are any machines for which this is not a correct
 --  assumption, a significant number of changes will be required.
 
+with Ada.Unchecked_Deallocation;
 with System;
 with Unchecked_Conversion;
-with Unchecked_Deallocation;
 
 package Types is
    pragma Preelaborate;
@@ -117,7 +117,7 @@ package Types is
    type String_Ptr_Const is access constant String;
    --  Standard character and string pointers
 
-   procedure Free is new Unchecked_Deallocation (String, String_Ptr);
+   procedure Free is new Ada.Unchecked_Deallocation (String, String_Ptr);
    --  Procedure for freeing dynamically allocated String values
 
    subtype Big_String is String (Positive);
@@ -155,7 +155,8 @@ package Types is
    --  Text buffers for input files are allocated dynamically and this type
    --  is used to reference these text buffers.
 
-   procedure Free is new Unchecked_Deallocation (Text_Buffer, Text_Buffer_Ptr);
+   procedure Free is
+     new Ada.Unchecked_Deallocation (Text_Buffer, Text_Buffer_Ptr);
    --  Procedure for freeing dynamically allocated text buffers
 
    ------------------------------------------


diff --git a/gcc/ada/xref_lib.adb b/gcc/ada/xref_lib.adb
--- a/gcc/ada/xref_lib.adb
+++ b/gcc/ada/xref_lib.adb
@@ -29,10 +29,9 @@ with Osint;
 with Output; use Output;
 with Types;  use Types;
 
-with Unchecked_Deallocation;
-
 with Ada.Strings.Fixed; use Ada.Strings.Fixed;
 with Ada.Text_IO;
+with Ada.Unchecked_Deallocation;
 
 with GNAT.Command_Line; use GNAT.Command_Line;
 with GNAT.IO_Aux;       use GNAT.IO_Aux;
@@ -1718,7 +1717,7 @@ package body Xref_Lib is
       Type_Tree     : Boolean)
    is
       type String_Access is access String;
-      procedure Free is new Unchecked_Deallocation (String, String_Access);
+      procedure Free is new Ada.Unchecked_Deallocation (String, String_Access);
 
       ALIfile   : ALI_File;
       File_Ref  : File_Reference;



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-13  8:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13  8:07 [Ada] Remove obsolete uses of Unchecked_Deallocation from Ada 83 Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).