From: Piotr Trojanek Date: Wed, 9 Feb 2022 21:32:19 +0000 (+0100) Subject: [Ada] Remove obsolete uses of Unchecked_Conversion from Ada 83 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83bacaa9b5d8b652f311633ca9584ea56cd71d86;p=platform%2Fupstream%2Fgcc.git [Ada] Remove obsolete uses of Unchecked_Conversion from Ada 83 Similar to a recent removal of obsolete uses of Unchecked_Deallocation. In Ada 83 the Unchecked_Conversion was a top-level unit; since Ada 95 it is an obsolete renaming of Ada.Unchecked_Conversion. GNAT doesn't warn yet about uses of these obsolete renamings, but it still seems better to avoid them. gcc/ada/ * atree.adb, gen_il-gen.adb, osint.adb, set_targ.adb, sinput.adb, table.adb, treepr.adb, types.ads: Replace uses of Unchecked_Conversion in the compiler itself. * libgnarl/a-reatim.adb, libgnarl/s-osinte__gnu.ads, libgnarl/s-osinte__kfreebsd-gnu.ads, libgnat/a-coboho.adb, libgnat/a-stuten.ads, libgnat/s-putima.adb: Likewise in the runtime. * doc/gnat_ugn/gnat_and_program_execution.rst: Likewise in documentation. * gnat_ugn.texi: Regenerate. --- diff --git a/gcc/ada/atree.adb b/gcc/ada/atree.adb index 08e3667..a949761 100644 --- a/gcc/ada/atree.adb +++ b/gcc/ada/atree.adb @@ -23,6 +23,7 @@ -- -- ------------------------------------------------------------------------------ +with Ada.Unchecked_Conversion; with Aspects; use Aspects; with Debug; use Debug; with Namet; use Namet; @@ -31,7 +32,6 @@ with Opt; use Opt; with Output; use Output; with Sinfo.Utils; use Sinfo.Utils; with System.Storage_Elements; -with Unchecked_Conversion; package body Atree is @@ -505,7 +505,7 @@ package body Atree is pragma Assert (Field_Type'Size = 1); function Cast is new - Unchecked_Conversion (Field_Size_1_Bit, Field_Type); + Ada.Unchecked_Conversion (Field_Size_1_Bit, Field_Type); Val : constant Field_Size_1_Bit := Get_1_Bit_Val (N, Offset); begin return Cast (Val); @@ -517,7 +517,7 @@ package body Atree is pragma Assert (Field_Type'Size = 2); function Cast is new - Unchecked_Conversion (Field_Size_2_Bit, Field_Type); + Ada.Unchecked_Conversion (Field_Size_2_Bit, Field_Type); Val : constant Field_Size_2_Bit := Get_2_Bit_Val (N, Offset); begin return Cast (Val); @@ -529,7 +529,7 @@ package body Atree is pragma Assert (Field_Type'Size = 4); function Cast is new - Unchecked_Conversion (Field_Size_4_Bit, Field_Type); + Ada.Unchecked_Conversion (Field_Size_4_Bit, Field_Type); Val : constant Field_Size_4_Bit := Get_4_Bit_Val (N, Offset); begin return Cast (Val); @@ -541,7 +541,7 @@ package body Atree is pragma Assert (Field_Type'Size = 8); function Cast is new - Unchecked_Conversion (Field_Size_8_Bit, Field_Type); + Ada.Unchecked_Conversion (Field_Size_8_Bit, Field_Type); Val : constant Field_Size_8_Bit := Get_8_Bit_Val (N, Offset); begin return Cast (Val); @@ -553,7 +553,7 @@ package body Atree is pragma Assert (Field_Type'Size = 32); function Cast is new - Unchecked_Conversion (Field_Size_32_Bit, Field_Type); + Ada.Unchecked_Conversion (Field_Size_32_Bit, Field_Type); Val : constant Field_Size_32_Bit := Get_32_Bit_Val (N, Offset); Result : constant Field_Type := Cast (Val); @@ -605,7 +605,7 @@ package body Atree is pragma Assert (Field_Type'Size = 1); function Cast is new - Unchecked_Conversion (Field_Type, Field_Size_1_Bit); + Ada.Unchecked_Conversion (Field_Type, Field_Size_1_Bit); begin Set_1_Bit_Val (N, Offset, Cast (Val)); end Set_1_Bit_Field; @@ -616,7 +616,7 @@ package body Atree is pragma Assert (Field_Type'Size = 2); function Cast is new - Unchecked_Conversion (Field_Type, Field_Size_2_Bit); + Ada.Unchecked_Conversion (Field_Type, Field_Size_2_Bit); begin Set_2_Bit_Val (N, Offset, Cast (Val)); end Set_2_Bit_Field; @@ -627,7 +627,7 @@ package body Atree is pragma Assert (Field_Type'Size = 4); function Cast is new - Unchecked_Conversion (Field_Type, Field_Size_4_Bit); + Ada.Unchecked_Conversion (Field_Type, Field_Size_4_Bit); begin Set_4_Bit_Val (N, Offset, Cast (Val)); end Set_4_Bit_Field; @@ -638,7 +638,7 @@ package body Atree is pragma Assert (Field_Type'Size = 8); function Cast is new - Unchecked_Conversion (Field_Type, Field_Size_8_Bit); + Ada.Unchecked_Conversion (Field_Type, Field_Size_8_Bit); begin Set_8_Bit_Val (N, Offset, Cast (Val)); end Set_8_Bit_Field; @@ -649,7 +649,7 @@ package body Atree is pragma Assert (Field_Type'Size = 32); function Cast is new - Unchecked_Conversion (Field_Type, Field_Size_32_Bit); + Ada.Unchecked_Conversion (Field_Type, Field_Size_32_Bit); begin Set_32_Bit_Val (N, Offset, Cast (Val)); end Set_32_Bit_Field; @@ -854,7 +854,7 @@ package body Atree is ---------------------- procedure Print_Atree_Info (N : Node_Or_Entity_Id) is - function Cast is new Unchecked_Conversion (Slot, Int); + function Cast is new Ada.Unchecked_Conversion (Slot, Int); begin Write_Int (Int (Size_In_Slots (N))); Write_Str (" slots ("); diff --git a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst index bf0fec9..c514678 100644 --- a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst +++ b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst @@ -2101,11 +2101,11 @@ the typing system. Consider the following complete program example: function to_a2 (Input : a1) return a2; end p2; - with Unchecked_Conversion; + with Ada.Unchecked_Conversion; package body p2 is function to_a2 (Input : a1) return a2 is function to_a2u is - new Unchecked_Conversion (a1, a2); + new Ada.Unchecked_Conversion (a1, a2); begin return to_a2u (Input); end to_a2; @@ -2198,7 +2198,7 @@ the warning off: pragma Warnings (Off); function to_a2u is - new Unchecked_Conversion (a1, a2); + new Ada.Unchecked_Conversion (a1, a2); pragma Warnings (On); Of course that approach is not appropriate for this particular diff --git a/gcc/ada/gen_il-gen.adb b/gcc/ada/gen_il-gen.adb index adf363b..0ecc696 100644 --- a/gcc/ada/gen_il-gen.adb +++ b/gcc/ada/gen_il-gen.adb @@ -1425,7 +1425,7 @@ package body Gen_IL.Gen is (S : in out Sink; T : Type_Enum) is Pre : constant String := - "function Cast is new Unchecked_Conversion ("; + "function Cast is new Ada.Unchecked_Conversion ("; Lo_Type : constant String := "Field_Size_" & Image (Field_Size (T)) & "_Bit"; Hi_Type : constant String := Get_Set_Id_Image (T); begin @@ -2338,7 +2338,7 @@ package body Gen_IL.Gen is Decrease_Indent (S, 3); Put (S, LF & "end Sinfo.Nodes;" & LF); - Put (B, "with Unchecked_Conversion;" & LF); + Put (B, "with Ada.Unchecked_Conversion;" & LF); Put (B, "with Atree; use Atree; use Atree.Atree_Private_Part;" & LF); Put (B, "with Nlists; use Nlists;" & LF); Put (B, "pragma Warnings (Off);" & LF); @@ -2394,7 +2394,7 @@ package body Gen_IL.Gen is Decrease_Indent (S, 3); Put (S, LF & "end Einfo.Entities;" & LF); - Put (B, "with Unchecked_Conversion;" & LF); + Put (B, "with Ada.Unchecked_Conversion;" & LF); Put (B, "with Atree; use Atree; use Atree.Atree_Private_Part;" & LF); Put (B, "with Einfo.Utils; use Einfo.Utils;" & LF); -- This forms a cycle between packages (via bodies, which is OK) diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 879f5fc..218c375 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -20478,11 +20478,11 @@ package p2 is function to_a2 (Input : a1) return a2; end p2; -with Unchecked_Conversion; +with Ada.Unchecked_Conversion; package body p2 is function to_a2 (Input : a1) return a2 is function to_a2u is - new Unchecked_Conversion (a1, a2); + new Ada.Unchecked_Conversion (a1, a2); begin return to_a2u (Input); end to_a2; @@ -20581,7 +20581,7 @@ the warning off: @example pragma Warnings (Off); function to_a2u is - new Unchecked_Conversion (a1, a2); + new Ada.Unchecked_Conversion (a1, a2); pragma Warnings (On); @end example @end quotation diff --git a/gcc/ada/libgnarl/a-reatim.adb b/gcc/ada/libgnarl/a-reatim.adb index 6bb5ae5..fda2d63 100644 --- a/gcc/ada/libgnarl/a-reatim.adb +++ b/gcc/ada/libgnarl/a-reatim.adb @@ -30,8 +30,8 @@ -- -- ------------------------------------------------------------------------------ +with Ada.Unchecked_Conversion; with System.Tasking; -with Unchecked_Conversion; package body Ada.Real_Time with SPARK_Mode => Off @@ -128,7 +128,7 @@ is type Duration_Rep is range -(2 ** 63) .. +((2 ** 63 - 1)); function To_Integer is - new Unchecked_Conversion (Duration, Duration_Rep); + new Ada.Unchecked_Conversion (Duration, Duration_Rep); begin return Integer (To_Integer (Duration (Left)) / To_Integer (Duration (Right))); diff --git a/gcc/ada/libgnarl/s-osinte__gnu.ads b/gcc/ada/libgnarl/s-osinte__gnu.ads index e763fc9..39e20f2 100644 --- a/gcc/ada/libgnarl/s-osinte__gnu.ads +++ b/gcc/ada/libgnarl/s-osinte__gnu.ads @@ -40,7 +40,7 @@ with Interfaces.C; with System.Parameters; -with Unchecked_Conversion; +with Ada.Unchecked_Conversion; package System.OS_Interface is pragma Preelaborate; @@ -288,14 +288,14 @@ package System.OS_Interface is pragma Convention (C, Thread_Body); function Thread_Body_Access is new - Unchecked_Conversion (System.Address, Thread_Body); + Ada.Unchecked_Conversion (System.Address, Thread_Body); -- From: /usr/include/bits/pthread.h:typedef int __pthread_t; -- /usr/include/pthread/pthreadtypes.h:typedef __pthread_t pthread_t; type pthread_t is new unsigned_long; subtype Thread_Id is pthread_t; - function To_pthread_t is new Unchecked_Conversion + function To_pthread_t is new Ada.Unchecked_Conversion (unsigned_long, pthread_t); type pthread_mutex_t is limited private; diff --git a/gcc/ada/libgnarl/s-osinte__kfreebsd-gnu.ads b/gcc/ada/libgnarl/s-osinte__kfreebsd-gnu.ads index c8d94e3..ad1a1b5 100644 --- a/gcc/ada/libgnarl/s-osinte__kfreebsd-gnu.ads +++ b/gcc/ada/libgnarl/s-osinte__kfreebsd-gnu.ads @@ -38,9 +38,9 @@ -- PLEASE DO NOT add any with-clauses to this package or remove the pragma -- Preelaborate. This package is designed to be a bottom-level (leaf) package +with Ada.Unchecked_Conversion; with Interfaces.C; with System.Parameters; -with Unchecked_Conversion; package System.OS_Interface is pragma Preelaborate; @@ -276,12 +276,12 @@ package System.OS_Interface is pragma Convention (C, Thread_Body); function Thread_Body_Access is new - Unchecked_Conversion (System.Address, Thread_Body); + Ada.Unchecked_Conversion (System.Address, Thread_Body); type pthread_t is new unsigned_long; subtype Thread_Id is pthread_t; - function To_pthread_t is new Unchecked_Conversion + function To_pthread_t is new Ada.Unchecked_Conversion (unsigned_long, pthread_t); type pthread_mutex_t is limited private; diff --git a/gcc/ada/libgnat/a-coboho.adb b/gcc/ada/libgnat/a-coboho.adb index db885b4..25d0777 100644 --- a/gcc/ada/libgnat/a-coboho.adb +++ b/gcc/ada/libgnat/a-coboho.adb @@ -25,7 +25,7 @@ -- . -- ------------------------------------------------------------------------------ -with Unchecked_Conversion; +with Ada.Unchecked_Conversion; with System.Put_Images; package body Ada.Containers.Bounded_Holders is @@ -54,7 +54,7 @@ package body Ada.Containers.Bounded_Holders is end Size_In_Storage_Elements; function Cast is new - Unchecked_Conversion (System.Address, Element_Access); + Ada.Unchecked_Conversion (System.Address, Element_Access); --------- -- "=" -- diff --git a/gcc/ada/libgnat/a-stuten.ads b/gcc/ada/libgnat/a-stuten.ads index 209c84a..618f5b0 100644 --- a/gcc/ada/libgnat/a-stuten.ads +++ b/gcc/ada/libgnat/a-stuten.ads @@ -36,8 +36,8 @@ -- UTF encoded strings. Note: this package is consistent with Ada 95, and may -- be used in Ada 95 or Ada 2005 mode. +with Ada.Unchecked_Conversion; with Interfaces; -with Unchecked_Conversion; package Ada.Strings.UTF_Encoding is pragma Pure (UTF_Encoding); @@ -106,13 +106,13 @@ package Ada.Strings.UTF_Encoding is private function To_Unsigned_8 is new - Unchecked_Conversion (Character, Interfaces.Unsigned_8); + Ada.Unchecked_Conversion (Character, Interfaces.Unsigned_8); function To_Unsigned_16 is new - Unchecked_Conversion (Wide_Character, Interfaces.Unsigned_16); + Ada.Unchecked_Conversion (Wide_Character, Interfaces.Unsigned_16); function To_Unsigned_32 is new - Unchecked_Conversion (Wide_Wide_Character, Interfaces.Unsigned_32); + Ada.Unchecked_Conversion (Wide_Wide_Character, Interfaces.Unsigned_32); subtype UTF_XE_Encoding is Encoding_Scheme range UTF_16BE .. UTF_16LE; -- Subtype containing only UTF_16BE and UTF_16LE entries diff --git a/gcc/ada/libgnat/s-putima.adb b/gcc/ada/libgnat/s-putima.adb index cc36fce..10d8b84 100644 --- a/gcc/ada/libgnat/s-putima.adb +++ b/gcc/ada/libgnat/s-putima.adb @@ -32,7 +32,7 @@ with Ada.Strings.Text_Buffers.Utils; use Ada.Strings.Text_Buffers; use Ada.Strings.Text_Buffers.Utils; -with Unchecked_Conversion; +with Ada.Unchecked_Conversion; package body System.Put_Images is @@ -133,7 +133,7 @@ package body System.Put_Images is procedure Put_Image_Pointer (S : in out Sink'Class; X : Pointer; Type_Kind : String) is - function Cast is new Unchecked_Conversion + function Cast is new Ada.Unchecked_Conversion (System.Address, Unsigned_Address); begin if X = null then diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb index af76dc7..15f0692 100644 --- a/gcc/ada/osint.adb +++ b/gcc/ada/osint.adb @@ -34,7 +34,7 @@ with Sdefault; use Sdefault; with Table; with Targparm; use Targparm; -with Unchecked_Conversion; +with Ada.Unchecked_Conversion; pragma Warnings (Off); -- This package is used also by gnatcoll @@ -2216,9 +2216,9 @@ package body Osint is -- GNAT releases are available with these functions. function To_Int is - new Unchecked_Conversion (OS_Time, Underlying_OS_Time); + new Ada.Unchecked_Conversion (OS_Time, Underlying_OS_Time); function From_Int is - new Unchecked_Conversion (Underlying_OS_Time, OS_Time); + new Ada.Unchecked_Conversion (Underlying_OS_Time, OS_Time); TI : Underlying_OS_Time := To_Int (T); Y : Year_Type; @@ -3085,8 +3085,8 @@ package body Osint is type Path_String_Access is access Path_String; function Address_To_Access is new - Unchecked_Conversion (Source => Address, - Target => Path_String_Access); + Ada.Unchecked_Conversion (Source => Address, + Target => Path_String_Access); Path_Access : constant Path_String_Access := Address_To_Access (Path_Addr); diff --git a/gcc/ada/set_targ.adb b/gcc/ada/set_targ.adb index dcb2fd0..160f510 100644 --- a/gcc/ada/set_targ.adb +++ b/gcc/ada/set_targ.adb @@ -31,7 +31,7 @@ with Output; use Output; with System; use System; with System.OS_Lib; use System.OS_Lib; -with Unchecked_Conversion; +with Ada.Unchecked_Conversion; package body Set_Targ is @@ -404,7 +404,7 @@ package body Set_Targ is -- Pointer to Nat or Pos value (it is harmless to treat Pos values and -- Nat values as Natural via Unchecked_Conversion). - function To_ANat is new Unchecked_Conversion (Address, ANat); + function To_ANat is new Ada.Unchecked_Conversion (Address, ANat); procedure AddC (C : Character); -- Add one character to buffer @@ -566,7 +566,7 @@ package body Set_Targ is -- Pointer to Nat or Pos value (it is harmless to treat Pos values -- as Nat via Unchecked_Conversion). - function To_ANat is new Unchecked_Conversion (Address, ANat); + function To_ANat is new Ada.Unchecked_Conversion (Address, ANat); VP : ANat; diff --git a/gcc/ada/sinput.adb b/gcc/ada/sinput.adb index fccbacf..8e80213 100644 --- 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_Conversion; with Ada.Unchecked_Deallocation; -with Unchecked_Conversion; package body Sinput is @@ -56,16 +56,16 @@ package body Sinput is -- used to construct improperly aliased pointer values. function To_Address is - new Unchecked_Conversion (Lines_Table_Ptr, Address); + new Ada.Unchecked_Conversion (Lines_Table_Ptr, Address); function To_Address is - new Unchecked_Conversion (Logical_Lines_Table_Ptr, Address); + new Ada.Unchecked_Conversion (Logical_Lines_Table_Ptr, Address); function To_Pointer is - new Unchecked_Conversion (Address, Lines_Table_Ptr); + new Ada.Unchecked_Conversion (Address, Lines_Table_Ptr); function To_Pointer is - new Unchecked_Conversion (Address, Logical_Lines_Table_Ptr); + new Ada.Unchecked_Conversion (Address, Logical_Lines_Table_Ptr); pragma Warnings (On); @@ -378,7 +378,7 @@ package body Sinput is -- to first Unchecked_Convert to access-to-variable. function To_Source_Buffer_Ptr_Var is new - Unchecked_Conversion (Source_Buffer_Ptr, Source_Buffer_Ptr_Var); + Ada.Unchecked_Conversion (Source_Buffer_Ptr, Source_Buffer_Ptr_Var); Temp : Source_Buffer_Ptr_Var := To_Source_Buffer_Ptr_Var (Src); diff --git a/gcc/ada/table.adb b/gcc/ada/table.adb index ce558cd..df467f4 100644 --- a/gcc/ada/table.adb +++ b/gcc/ada/table.adb @@ -30,7 +30,7 @@ with System; use System; with System.Memory; use System.Memory; -with Unchecked_Conversion; +with Ada.Unchecked_Conversion; pragma Elaborate_All (Output); @@ -58,8 +58,8 @@ package body Table is -- internally in this package, and cannot never result in any instances -- of improperly aliased pointers for the client of the package. - function To_Address is new Unchecked_Conversion (Table_Ptr, Address); - function To_Pointer is new Unchecked_Conversion (Address, Table_Ptr); + function To_Address is new Ada.Unchecked_Conversion (Table_Ptr, Address); + function To_Pointer is new Ada.Unchecked_Conversion (Address, Table_Ptr); pragma Warnings (On); diff --git a/gcc/ada/treepr.adb b/gcc/ada/treepr.adb index 4fd082a..32f6e81 100644 --- a/gcc/ada/treepr.adb +++ b/gcc/ada/treepr.adb @@ -23,6 +23,7 @@ -- -- ------------------------------------------------------------------------------ +with Ada.Unchecked_Conversion; with Aspects; use Aspects; with Atree; use Atree; with Debug; use Debug; @@ -49,7 +50,6 @@ with SCIL_LL; use SCIL_LL; with Uintp; use Uintp; with Urealp; use Urealp; with Uname; use Uname; -with Unchecked_Conversion; package body Treepr is @@ -132,8 +132,8 @@ package body Treepr is -- Local Procedures -- ---------------------- - function From_Union is new Unchecked_Conversion (Union_Id, Uint); - function From_Union is new Unchecked_Conversion (Union_Id, Ureal); + function From_Union is new Ada.Unchecked_Conversion (Union_Id, Uint); + function From_Union is new Ada.Unchecked_Conversion (Union_Id, Ureal); function To_Mixed (S : String) return String; -- Turns an identifier into Mixed_Case. For bootstrap reasons, we cannot @@ -260,7 +260,7 @@ package body Treepr is ---------- function Hash (Key : Int) return GNAT.Bucket_Range_Type is - function Cast is new Unchecked_Conversion + function Cast is new Ada.Unchecked_Conversion (Source => Int, Target => GNAT.Bucket_Range_Type); begin return Cast (Key); @@ -880,7 +880,7 @@ package body Treepr is when Uint_Field => declare Val : constant Uint := Get_Uint (N, FD.Offset); - function Cast is new Unchecked_Conversion (Uint, Int); + function Cast is new Ada.Unchecked_Conversion (Uint, Int); begin if Present (Val) then Print_Initial; @@ -895,7 +895,7 @@ package body Treepr is | Nonzero_Uint_Field => declare Val : constant Uint := Get_Valid_Uint (N, FD.Offset); - function Cast is new Unchecked_Conversion (Uint, Int); + function Cast is new Ada.Unchecked_Conversion (Uint, Int); begin Print_Initial; UI_Write (Val, Format); @@ -916,7 +916,7 @@ package body Treepr is when Ureal_Field => declare Val : constant Ureal := Get_Ureal (N, FD.Offset); - function Cast is new Unchecked_Conversion (Ureal, Int); + function Cast is new Ada.Unchecked_Conversion (Ureal, Int); begin if Val /= No_Ureal then Print_Initial; @@ -980,7 +980,8 @@ package body Treepr is exception when others => declare - function Cast is new Unchecked_Conversion (Field_Size_32_Bit, Int); + function Cast is new + Ada.Unchecked_Conversion (Field_Size_32_Bit, Int); begin Write_Eol; Print_Initial; diff --git a/gcc/ada/types.ads b/gcc/ada/types.ads index de14bf7..3b226e1 100644 --- 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_Conversion; with Ada.Unchecked_Deallocation; with System; -with Unchecked_Conversion; package Types is pragma Preelaborate; @@ -127,7 +127,7 @@ package Types is -- size of zero, since there are legitimate deallocations going on. function To_Big_String_Ptr is - new Unchecked_Conversion (System.Address, Big_String_Ptr); + new Ada.Unchecked_Conversion (System.Address, Big_String_Ptr); -- Used to obtain Big_String_Ptr values from external addresses subtype Word_Hex_String is String (1 .. 8);