1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 13:09:22 +00:00

Avoid 'warning: implicit conversion changes signedness' in output code.

This commit is contained in:
Bruno Haible
2016-11-26 02:21:19 +01:00
parent b3356507ce
commit bbe4d732f3
16 changed files with 44 additions and 32 deletions

View File

@@ -1,3 +1,11 @@
2016-11-26 Bruno Haible <bruno@clisp.org>
Avoid 'warning: implicit conversion changes signedness' in output code.
* src/output.cc (Output::output_lookup_function_body): Emit declaration
of 'key' as 'unsigned int', not 'int'. Optimize comparison accordingly.
* tests/*.exp: Update.
Reported at <https://savannah.gnu.org/bugs/?44887>.
2016-11-26 Bruno Haible <bruno@clisp.org>
Avoid 'warning: implicit conversion changes signedness' in output code.

View File

@@ -1615,7 +1615,7 @@ Output::output_lookup_function_body (const Output_Compare& comparison) const
{
printf (" if (len <= %sMAX_WORD_LENGTH && len >= %sMIN_WORD_LENGTH)\n"
" {\n"
" register int key = %s (str, len);\n\n",
" register unsigned int key = %s (str, len);\n\n",
option.get_constants_prefix (), option.get_constants_prefix (),
option.get_hash_name ());
@@ -1626,9 +1626,13 @@ Output::output_lookup_function_body (const Output_Compare& comparison) const
if (num_switches > switch_size)
num_switches = switch_size;
printf (" if (key <= %sMAX_HASH_VALUE && key >= %sMIN_HASH_VALUE)\n"
" {\n",
option.get_constants_prefix (), option.get_constants_prefix ());
printf (" if (key <= %sMAX_HASH_VALUE",
option.get_constants_prefix ());
if (_min_hash_value > 0)
printf (" && key >= %sMIN_HASH_VALUE",
option.get_constants_prefix ());
printf (")\n"
" {\n");
if (option[DUP] && _total_duplicates > 0)
{
if (option[LENTABLE])
@@ -1726,7 +1730,7 @@ Output::output_lookup_function_body (const Output_Compare& comparison) const
}
else
{
printf (" if (key <= %sMAX_HASH_VALUE && key >= 0)\n",
printf (" if (key <= %sMAX_HASH_VALUE)\n",
option.get_constants_prefix ());
if (option[DUP])

View File

@@ -210,9 +210,9 @@ is_reserved_word (str, len)
{
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key].name;

View File

@@ -1812,9 +1812,9 @@ in_word_set (register const char *str, register unsigned int len)
{
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key].name;

View File

@@ -502,7 +502,7 @@ in_word_set (str, len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
{

View File

@@ -255,9 +255,9 @@ is_reserved_word (str, len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key].name;

View File

@@ -142,9 +142,9 @@ is_reserved_word (register const char *str, register unsigned int len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key].name;

View File

@@ -110,9 +110,9 @@ in_word_set (register const char *str, register unsigned int len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key].name;

View File

@@ -194,9 +194,9 @@ java_keyword (str, len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key].name;

View File

@@ -1469,9 +1469,9 @@ in_word_set (register const char *str, register unsigned int len)
{
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key].name;

View File

@@ -206,9 +206,9 @@ in_word_set (register const char *str, register unsigned int len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
if (len == lengthtable[key])
{
register const char *s = wordlist[key];

View File

@@ -178,9 +178,9 @@ is_reserved_word (register const char *str, register unsigned int len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key].name;

View File

@@ -99,9 +99,9 @@ in_word_set (register const char *str, register unsigned int len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key];

View File

@@ -99,9 +99,9 @@ in_word_set (register const char *str, register unsigned int len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key];

View File

@@ -148,9 +148,9 @@ in_word_set (register const char *str, register unsigned int len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key];

View File

@@ -199,9 +199,9 @@ in_word_set (register const char *str, register unsigned int len)
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
register unsigned int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register int index = lookup[key];