OSDN Git Service

2007-08-14 Gary Dismukes <dismukes@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Aug 2007 08:50:18 +0000 (08:50 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Aug 2007 08:50:18 +0000 (08:50 +0000)
* s-veboop.adb (SU): New named number initialized to
System.Storage_Unit.
(True_Val): The initialization expression is revised to use SU (=
Storage_Unit) rather than assuming 8 for the component size of an
unpacked Boolean array.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127465 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/s-veboop.adb

index 177a944..27f68a2 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2002-2005, Free Software Foundation, Inc.         --
+--          Copyright (C) 2002-2007, 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- --
 
 package body System.Vectors.Boolean_Operations is
 
+   SU : constant := Storage_Unit;
+   --  Convenient short hand, used throughout
+
+   --  The coding of this unit depends on the fact that the Component_Size
+   --  of a normally declared array of Boolean is equal to Storage_Unit. We
+   --  can't use the Component_Size directly since it is non-static. The
+   --  following declaration checks that this declaration is correct
+
    type Boolean_Array is array (Integer range <>) of Boolean;
-   pragma Assert (Boolean_Array'Component_Size = 8);
-   --  Unfortunately Boolean_Array'Component_Size is not a compile-time-known
-   --  value, so assume it is 8 in order to be able to determine True_Val at
-   --  compile time.
+   pragma Compile_Time_Error
+     (Boolean_Array'Component_Size /= SU, "run time compile failure");
 
    --  NOTE: The boolean literals must be qualified here to avoid visibility
    --  anomalies when this package is compiled through Rtsfind, in a context
    --  that includes a user-defined type derived from boolean.
 
    True_Val : constant Vector := Standard.True'Enum_Rep
-                                   + Standard.True'Enum_Rep * 2**8
-                                   + Standard.True'Enum_Rep * 2**(8 * 2)
-                                   + Standard.True'Enum_Rep * 2**(8 * 3)
-                                   + Standard.True'Enum_Rep * 2**(8 * 4)
-                                   + Standard.True'Enum_Rep * 2**(8 * 5)
-                                   + Standard.True'Enum_Rep * 2**(8 * 6)
-                                   + Standard.True'Enum_Rep * 2**(8 * 7);
+                                   + Standard.True'Enum_Rep * 2**SU
+                                   + Standard.True'Enum_Rep * 2**(SU * 2)
+                                   + Standard.True'Enum_Rep * 2**(SU * 3)
+                                   + Standard.True'Enum_Rep * 2**(SU * 4)
+                                   + Standard.True'Enum_Rep * 2**(SU * 5)
+                                   + Standard.True'Enum_Rep * 2**(SU * 6)
+                                   + Standard.True'Enum_Rep * 2**(SU * 7);
    --  This constant represents the bits to be flipped to perform a logical
    --  "not" on a vector of booleans, independent of the actual
    --  representation of True.