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.
-- --
------------------------------------------------------------------------------
+with Ada.Unchecked_Conversion;
with Aspects; use Aspects;
with Debug; use Debug;
with Namet; use Namet;
with Output; use Output;
with Sinfo.Utils; use Sinfo.Utils;
with System.Storage_Elements;
-with Unchecked_Conversion;
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);
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);
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);
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);
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);
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;
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;
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;
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;
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;
----------------------
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 (");
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;
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
(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
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);
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)
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;
@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
-- --
------------------------------------------------------------------------------
+with Ada.Unchecked_Conversion;
with System.Tasking;
-with Unchecked_Conversion;
package body Ada.Real_Time with
SPARK_Mode => Off
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)));
with Interfaces.C;
with System.Parameters;
-with Unchecked_Conversion;
+with Ada.Unchecked_Conversion;
package System.OS_Interface is
pragma Preelaborate;
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;
-- 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;
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;
-- <http://www.gnu.org/licenses/>. --
------------------------------------------------------------------------------
-with Unchecked_Conversion;
+with Ada.Unchecked_Conversion;
with System.Put_Images;
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);
---------
-- "=" --
-- 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);
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
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
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
with Table;
with Targparm; use Targparm;
-with Unchecked_Conversion;
+with Ada.Unchecked_Conversion;
pragma Warnings (Off);
-- This package is used also by gnatcoll
-- 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;
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);
with System; use System;
with System.OS_Lib; use System.OS_Lib;
-with Unchecked_Conversion;
+with Ada.Unchecked_Conversion;
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
-- 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;
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
-- 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);
-- 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);
with System.Memory; use System.Memory;
-with Unchecked_Conversion;
+with Ada.Unchecked_Conversion;
pragma Elaborate_All (Output);
-- 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);
-- --
------------------------------------------------------------------------------
+with Ada.Unchecked_Conversion;
with Aspects; use Aspects;
with Atree; use Atree;
with Debug; use Debug;
with Uintp; use Uintp;
with Urealp; use Urealp;
with Uname; use Uname;
-with Unchecked_Conversion;
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
----------
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);
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;
| 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);
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;
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;
-- 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;
-- 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);