OSDN Git Service

2005-03-29 Vincent Celier <celier@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-sequio.adb
index 1aed601..7218763 100644 (file)
@@ -6,8 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                                                                          --
---          Copyright (C) 1992-1999, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2003, Free Software Foundation, Inc.         --
 --                                                                          --
 -- 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- --
@@ -28,7 +27,7 @@
 -- covered by the  GNU Public License.                                      --
 --                                                                          --
 -- GNAT was originally developed  by the GNAT team at  New York University. --
--- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
 --                                                                          --
 ------------------------------------------------------------------------------
 
@@ -39,6 +38,7 @@
 
 with Interfaces.C_Streams; use Interfaces.C_Streams;
 with System;
+with System.CRTL;
 with System.File_Control_Block;
 with System.File_IO;
 with System.Storage_Elements;
@@ -59,6 +59,8 @@ package body Ada.Sequential_IO is
    function To_FCB is new Unchecked_Conversion (File_Mode, FCB.File_Mode);
    function To_SIO is new Unchecked_Conversion (FCB.File_Mode, File_Mode);
 
+   use type System.CRTL.size_t;
+
    -----------
    -- Close --
    -----------
@@ -184,15 +186,21 @@ package body Ada.Sequential_IO is
                RsizS : constant SSE.Storage_Offset :=
                          SSE.Storage_Offset (Rsiz - 1);
 
-               subtype SA is SSE.Storage_Array (0 .. RsizS);
+               type SA is new SSE.Storage_Array (0 .. RsizS);
+
+               for SA'Alignment use Standard'Maximum_Alignment;
+               --  We will perform an unchecked conversion of a pointer-to-SA
+               --  into pointer-to-Element_Type. We need to ensure that the
+               --  source is always at least as strictly aligned as the target.
+
                type SAP   is access all SA;
                type ItemP is access all Element_Type;
 
                pragma Warnings (Off);
-               --  We have to turn warnings off for this function, because
-               --  it gets analyzed for all types, including ones which
-               --  can't possibly come this way, and for which the size
-               --  of the access types differs.
+               --  We have to turn warnings off for function To_ItemP,
+               --  because it gets analyzed for all types, including ones
+               --  which can't possibly come this way, and for which the
+               --  size of the access types differs.
 
                function To_ItemP is new Unchecked_Conversion (SAP, ItemP);