OSDN Git Service

2007-04-20 Ed Schonberg <schonberg@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / g-table.adb
index 57f7c72..f16b6fd 100644 (file)
@@ -1,12 +1,12 @@
 ------------------------------------------------------------------------------
 --                                                                          --
---                         GNAT RUNTIME COMPONENTS                          --
+--                         GNAT RUN-TIME COMPONENTS                         --
 --                                                                          --
---                            G N A T .  T A B L E                          --
+--                            G N A T . T A B L E                           --
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---            Copyright (C) 1998-2002 Ada Core Technologies, Inc.           --
+--                     Copyright (C) 1998-2007, AdaCore                     --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -16,8 +16,8 @@
 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
 -- for  more details.  You should have  received  a copy of the GNU General --
 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.                                              --
 --                                                                          --
 -- As a special exception,  if other files  instantiate  generics from this --
 -- unit, or you link  this unit with other files  to produce an executable, --
@@ -34,7 +34,7 @@
 with System;        use System;
 with System.Memory; use System.Memory;
 
-with Unchecked_Conversion;
+with Ada.Unchecked_Conversion;
 
 package body GNAT.Table is
 
@@ -49,7 +49,7 @@ package body GNAT.Table is
    --  ensures that we initially allocate the table.
 
    Last_Val : Integer;
-   --  Current value of Last.
+   --  Current value of Last
 
    -----------------------
    -- Local Subprograms --
@@ -60,8 +60,15 @@ package body GNAT.Table is
    --  in Max. Works correctly to do an initial allocation if the table
    --  is currently null.
 
-   function To_Address is new Unchecked_Conversion (Table_Ptr, Address);
-   function To_Pointer is new Unchecked_Conversion (Address, Table_Ptr);
+   pragma Warnings (Off);
+   --  Turn off warnings. The following unchecked conversions are only used
+   --  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 Ada.Unchecked_Conversion (Table_Ptr, Address);
+   function To_Pointer is new Ada.Unchecked_Conversion (Address, Table_Ptr);
+
+   pragma Warnings (On);
 
    --------------
    -- Allocate --
@@ -224,7 +231,7 @@ package body GNAT.Table is
       Item  : Table_Component_Type)
    is
    begin
-      if Integer (Index) > Max then
+      if Integer (Index) > Last_Val then
          Set_Last (Index);
       end if;