This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Restrict s-strhas to 32-bit modular types


The Hash generic in System.String_Hash is designed to work with 32-bit
unsigned types. This patch documents and enforces (Compile_Time_Error)
this requirement. All the uses in the run-time library follow this rule,
and the routine is not intended to be user accessible, so this should
not cause any difficulties in existing code.

The following is a test program (compiled with -gnatl -gnatws -gnatj50)

     1. with System.String_Hash;
     2. procedure THash is
     3.    type Hash_Type is mod 22;
     4.    function Hash is new System.String_Hash.Hash
           |
        >>> instantiation error at
            s-strhas.adb:46, Hash_Type must be
            32-bit modular with range 0 .. 2**32-1

     5.      (Character, String, Hash_Type);
     6.    R : Hash_Type := Hash ("toto titi tata");
     7. begin
     8.    null;
     9. end THash;

Tested on x86_64-pc-linux-gnu, committed on trunk

2009-06-23  Robert Dewar  <dewar@adacore.com>

	* s-strhas.adb, s-strhas.ads: Restrict to 32-bit modular types

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]