public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [Ada] Remove obsolete uses of Unchecked_Deallocation from Ada 83
Date: Fri, 13 May 2022 08:07:34 +0000	[thread overview]
Message-ID: <20220513080734.GA2456672@adacore.com> (raw)

[-- 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;



                 reply	other threads:[~2022-05-13  8:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220513080734.GA2456672@adacore.com \
    --to=derodat@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=trojanek@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).