From bbe4d732f3540e2917d35d5ae49ba42869eebb3b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 26 Nov 2016 02:21:19 +0100 Subject: Avoid 'warning: implicit conversion changes signedness' in output code. --- ChangeLog | 8 ++++++++ src/output.cc | 14 +++++++++----- tests/c-parse.exp | 4 ++-- tests/charsets.exp | 4 ++-- tests/chill.exp | 2 +- tests/cplusplus.exp | 4 ++-- tests/gpc.exp | 4 ++-- tests/incomplete.exp | 4 ++-- tests/java.exp | 4 ++-- tests/languages.exp | 4 ++-- tests/modula2.exp | 4 ++-- tests/objc.exp | 4 ++-- tests/permut2.exp | 4 ++-- tests/permut3.exp | 4 ++-- tests/permutc2.exp | 4 ++-- tests/test-4.exp | 4 ++-- 16 files changed, 44 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index f1a2d60..349b116 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2016-11-26 Bruno Haible + + 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 . + 2016-11-26 Bruno Haible Avoid 'warning: implicit conversion changes signedness' in output code. diff --git a/src/output.cc b/src/output.cc index d01687c..e60f8f7 100644 --- a/src/output.cc +++ b/src/output.cc @@ -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]) diff --git a/tests/c-parse.exp b/tests/c-parse.exp index 1efb61b..e526710 100644 --- a/tests/c-parse.exp +++ b/tests/c-parse.exp @@ -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; diff --git a/tests/charsets.exp b/tests/charsets.exp index 560af1b..7e2b988 100644 --- a/tests/charsets.exp +++ b/tests/charsets.exp @@ -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; diff --git a/tests/chill.exp b/tests/chill.exp index 401b6b8..8fa7879 100644 --- a/tests/chill.exp +++ b/tests/chill.exp @@ -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) { diff --git a/tests/cplusplus.exp b/tests/cplusplus.exp index c28cf61..69c2fd0 100644 --- a/tests/cplusplus.exp +++ b/tests/cplusplus.exp @@ -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; diff --git a/tests/gpc.exp b/tests/gpc.exp index b2a77b6..59b5a18 100644 --- a/tests/gpc.exp +++ b/tests/gpc.exp @@ -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; diff --git a/tests/incomplete.exp b/tests/incomplete.exp index ab4e24f..dfb0b57 100644 --- a/tests/incomplete.exp +++ b/tests/incomplete.exp @@ -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; diff --git a/tests/java.exp b/tests/java.exp index b7b0fed..465d6d9 100644 --- a/tests/java.exp +++ b/tests/java.exp @@ -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; diff --git a/tests/languages.exp b/tests/languages.exp index 6e7cfe5..051c8e0 100644 --- a/tests/languages.exp +++ b/tests/languages.exp @@ -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; diff --git a/tests/modula2.exp b/tests/modula2.exp index c6c8806..3c6451d 100644 --- a/tests/modula2.exp +++ b/tests/modula2.exp @@ -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]; diff --git a/tests/objc.exp b/tests/objc.exp index 363346f..78680c5 100644 --- a/tests/objc.exp +++ b/tests/objc.exp @@ -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; diff --git a/tests/permut2.exp b/tests/permut2.exp index 7db6857..5d29a91 100644 --- a/tests/permut2.exp +++ b/tests/permut2.exp @@ -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]; diff --git a/tests/permut3.exp b/tests/permut3.exp index 967c084..2612088 100644 --- a/tests/permut3.exp +++ b/tests/permut3.exp @@ -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]; diff --git a/tests/permutc2.exp b/tests/permutc2.exp index 4a29918..157b049 100644 --- a/tests/permutc2.exp +++ b/tests/permutc2.exp @@ -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]; diff --git a/tests/test-4.exp b/tests/test-4.exp index 2b97abc..e860053 100644 --- a/tests/test-4.exp +++ b/tests/test-4.exp @@ -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]; -- cgit v1.2.1