mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 21:19:24 +00:00
Avoid "gcc -Wunused-parameter" warnings on the generated hash function.
Reported by Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com> in <https://savannah.gnu.org/bugs/index.php?64393>. * src/output.cc (Output::output_hash_function): If str is not used, emit a cast from str to void. If len is not used, emit a cast from len to void. * tests/permut2.exp: Update. * tests/permut3.exp: Likewise. * tests/permutc2.exp: Likewise.
This commit is contained in:
12
ChangeLog
12
ChangeLog
@@ -1,3 +1,15 @@
|
|||||||
|
2023-07-08 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
|
Avoid "gcc -Wunused-parameter" warnings on the generated hash function.
|
||||||
|
Reported by Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com> in
|
||||||
|
<https://savannah.gnu.org/bugs/index.php?64393>.
|
||||||
|
* src/output.cc (Output::output_hash_function): If str is not used, emit
|
||||||
|
a cast from str to void. If len is not used, emit a cast from len to
|
||||||
|
void.
|
||||||
|
* tests/permut2.exp: Update.
|
||||||
|
* tests/permut3.exp: Likewise.
|
||||||
|
* tests/permutc2.exp: Likewise.
|
||||||
|
|
||||||
2023-07-01 Bruno Haible <bruno@clisp.org>
|
2023-07-01 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
doc: Tweaks.
|
doc: Tweaks.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Output routines.
|
/* Output routines.
|
||||||
Copyright (C) 1989-1998, 2000, 2002-2004, 2006-2007, 2009, 2011-2012, 2016, 2018, 2021 Free Software Foundation, Inc.
|
Copyright (C) 1989-1998, 2000, 2002-2004, 2006-2007, 2009, 2011-2012, 2016, 2018, 2021, 2023 Free Software Foundation, Inc.
|
||||||
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
|
||||||
and Bruno Haible <bruno@clisp.org>.
|
and Bruno Haible <bruno@clisp.org>.
|
||||||
|
|
||||||
@@ -815,12 +815,15 @@ Output::output_hash_function () const
|
|||||||
"#endif\n"
|
"#endif\n"
|
||||||
"#endif\n");
|
"#endif\n");
|
||||||
|
|
||||||
if (/* The function does not use the 'str' argument? */
|
/* Does the function use the 'str' argument? */
|
||||||
_key_positions.get_size() == 0
|
bool uses_str = (_key_positions.get_size() > 0);
|
||||||
|| /* The function uses 'str', but not the 'len' argument? */
|
/* Does the function use the 'len' argument? */
|
||||||
(!_hash_includes_len
|
bool uses_len =
|
||||||
&& _key_positions[0] < _min_key_len
|
(_hash_includes_len
|
||||||
&& _key_positions[_key_positions.get_size() - 1] != Positions::LASTCHAR))
|
|| (_key_positions.get_size() > 0
|
||||||
|
&& (_key_positions[0] >= _min_key_len
|
||||||
|
|| _key_positions[_key_positions.get_size() - 1] == Positions::LASTCHAR)));
|
||||||
|
if (!uses_str || !uses_len)
|
||||||
/* Pacify lint. */
|
/* Pacify lint. */
|
||||||
printf ("/*ARGSUSED*/\n");
|
printf ("/*ARGSUSED*/\n");
|
||||||
|
|
||||||
@@ -830,6 +833,9 @@ Output::output_hash_function () const
|
|||||||
if (option[CPLUSPLUS])
|
if (option[CPLUSPLUS])
|
||||||
printf ("%s::", option.get_class_name ());
|
printf ("%s::", option.get_class_name ());
|
||||||
printf ("%s ", option.get_hash_name ());
|
printf ("%s ", option.get_hash_name ());
|
||||||
|
/* We better not use [[__maybe_unused__]] or __attribute__ ((__unused__))
|
||||||
|
because support for these syntaxes in the compilers is constantly
|
||||||
|
changing. */
|
||||||
printf (option[KRC] ?
|
printf (option[KRC] ?
|
||||||
"(str, len)\n"
|
"(str, len)\n"
|
||||||
" %schar *str;\n"
|
" %schar *str;\n"
|
||||||
@@ -879,6 +885,15 @@ Output::output_hash_function () const
|
|||||||
" };\n");
|
" };\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!uses_str)
|
||||||
|
/* The function does not use the 'str' argument.
|
||||||
|
Silence "gcc -Wunused-parameter". */
|
||||||
|
printf (" (void) str;\n");
|
||||||
|
if (!uses_len)
|
||||||
|
/* The function does not use the 'len' argument.
|
||||||
|
Silence "gcc -Wunused-parameter". */
|
||||||
|
printf (" (void) len;\n");
|
||||||
|
|
||||||
if (_key_positions.get_size() == 0)
|
if (_key_positions.get_size() == 0)
|
||||||
{
|
{
|
||||||
/* Trivial case: No key positions at all. */
|
/* Trivial case: No key positions at all. */
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ hash (register const char *str, register size_t len)
|
|||||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
4, 4, 4, 4, 4, 4, 4
|
4, 4, 4, 4, 4, 4, 4
|
||||||
};
|
};
|
||||||
|
(void) len;
|
||||||
return asso_values[(unsigned char)str[1]+1] + asso_values[(unsigned char)str[0]];
|
return asso_values[(unsigned char)str[1]+1] + asso_values[(unsigned char)str[0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ hash (register const char *str, register size_t len)
|
|||||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||||
4, 4, 4, 4, 4, 4, 4
|
4, 4, 4, 4, 4, 4, 4
|
||||||
};
|
};
|
||||||
|
(void) len;
|
||||||
return asso_values[(unsigned char)str[1]+1] + asso_values[(unsigned char)str[0]];
|
return asso_values[(unsigned char)str[1]+1] + asso_values[(unsigned char)str[0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ hash (register const char *str, register size_t len)
|
|||||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||||
8, 8, 8, 8, 8, 8, 8, 8, 8
|
8, 8, 8, 8, 8, 8, 8, 8, 8
|
||||||
};
|
};
|
||||||
|
(void) len;
|
||||||
return asso_values[(unsigned char)str[1]+3] + asso_values[(unsigned char)str[0]];
|
return asso_values[(unsigned char)str[1]+3] + asso_values[(unsigned char)str[0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user