summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2016-11-26 02:21:19 +0100
committerBruno Haible <bruno@clisp.org>2016-11-26 02:25:44 +0100
commitbbe4d732f3540e2917d35d5ae49ba42869eebb3b (patch)
tree202f2d0583ad5c0505d058e203b448677749d7e7
parentb3356507ce8a6e2636fcc22abb7965989f7f4d07 (diff)
downloadgperf-bbe4d732f3540e2917d35d5ae49ba42869eebb3b.tar.gz
Avoid 'warning: implicit conversion changes signedness' in output code.
-rw-r--r--ChangeLog8
-rw-r--r--src/output.cc14
-rw-r--r--tests/c-parse.exp4
-rw-r--r--tests/charsets.exp4
-rw-r--r--tests/chill.exp2
-rw-r--r--tests/cplusplus.exp4
-rw-r--r--tests/gpc.exp4
-rw-r--r--tests/incomplete.exp4
-rw-r--r--tests/java.exp4
-rw-r--r--tests/languages.exp4
-rw-r--r--tests/modula2.exp4
-rw-r--r--tests/objc.exp4
-rw-r--r--tests/permut2.exp4
-rw-r--r--tests/permut3.exp4
-rw-r--r--tests/permutc2.exp4
-rw-r--r--tests/test-4.exp4
16 files changed, 44 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index f1a2d60..349b116 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
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.
* src/output.cc (Output::output_hash_function): Emit declaration of
'hval' as 'unsigned int', not 'int'.
* tests/*.exp: Update.
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];