mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Avoid "-Wzero-as-null-pointer-constant" warnings on the generated code.
Reported in <https://lists.gnu.org/archive/html/bug-gnulib/2024-11/msg00123.html>. * src/output.cc (Output::output_lookup_function_body): To denote a null pointer, emit a cast expression instead of plain "0". * tests/c-parse.exp, tests/charsets.exp, tests/chill.exp, tests/cplusplus.exp, tests/gpc.exp, tests/incomplete.exp, tests/java.exp, tests/languages.exp, tests/modula2.exp, tests/objc.exp, tests/permut2.exp, tests/permut3.exp, tests/permutc2.exp, tests/test-4.exp: Update.
This commit is contained in:
13
ChangeLog
13
ChangeLog
@@ -1,3 +1,16 @@
|
|||||||
|
2024-11-16 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
|
Avoid "-Wzero-as-null-pointer-constant" warnings on the generated code.
|
||||||
|
Reported in
|
||||||
|
<https://lists.gnu.org/archive/html/bug-gnulib/2024-11/msg00123.html>.
|
||||||
|
* src/output.cc (Output::output_lookup_function_body): To denote a null
|
||||||
|
pointer, emit a cast expression instead of plain "0".
|
||||||
|
* tests/c-parse.exp, tests/charsets.exp, tests/chill.exp,
|
||||||
|
tests/cplusplus.exp, tests/gpc.exp, tests/incomplete.exp,
|
||||||
|
tests/java.exp, tests/languages.exp, tests/modula2.exp, tests/objc.exp,
|
||||||
|
tests/permut2.exp, tests/permut3.exp, tests/permutc2.exp,
|
||||||
|
tests/test-4.exp: Update.
|
||||||
|
|
||||||
2024-10-28 Bruno Haible <bruno@clisp.org>
|
2024-10-28 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
doc: Improve text rendering in PDF output.
|
doc: Improve text rendering in PDF output.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Output routines.
|
/* Output routines.
|
||||||
Copyright (C) 1989-1998, 2000, 2002-2004, 2006-2007, 2009, 2011-2012, 2016, 2018, 2021, 2023 Free Software Foundation, Inc.
|
Copyright (C) 1989-2024 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>.
|
||||||
|
|
||||||
@@ -1707,6 +1707,17 @@ output_switches (KeywordExt_List *list, int num_switches, int size, int min_hash
|
|||||||
void
|
void
|
||||||
Output::output_lookup_function_body (const Output_Compare& comparison) const
|
Output::output_lookup_function_body (const Output_Compare& comparison) const
|
||||||
{
|
{
|
||||||
|
/* An expression equivalent to NULL, of type _return_type.
|
||||||
|
We don't use plain "0", because that would trigger a gcc 15 warning
|
||||||
|
if the warning option -Wzero-as-null-pointer-constant is in use.
|
||||||
|
In C++, using "nullptr" if __cplusplus >= 201103L would be possible,
|
||||||
|
but is not worth the trouble. */
|
||||||
|
char *null_expression = new char[17 + strlen (_return_type) + 1];
|
||||||
|
if (option[CPLUSPLUS])
|
||||||
|
sprintf (null_expression, "static_cast<%s> (0)", _return_type);
|
||||||
|
else
|
||||||
|
sprintf (null_expression, "(%s) 0", _return_type);
|
||||||
|
|
||||||
printf (" if (len <= %sMAX_WORD_LENGTH && len >= %sMIN_WORD_LENGTH)\n"
|
printf (" if (len <= %sMAX_WORD_LENGTH && len >= %sMIN_WORD_LENGTH)\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
" %sunsigned int key = %s (str, len);\n\n",
|
" %sunsigned int key = %s (str, len);\n\n",
|
||||||
@@ -1755,7 +1766,8 @@ Output::output_lookup_function_body (const Output_Compare& comparison) const
|
|||||||
|
|
||||||
output_switches (_head, num_switches, switch_size, _min_hash_value, _max_hash_value, 10);
|
output_switches (_head, num_switches, switch_size, _min_hash_value, _max_hash_value, 10);
|
||||||
|
|
||||||
printf (" return 0;\n");
|
printf (" return %s;\n",
|
||||||
|
null_expression);
|
||||||
if (option[DUP] && _total_duplicates > 0)
|
if (option[DUP] && _total_duplicates > 0)
|
||||||
{
|
{
|
||||||
int indent = 8;
|
int indent = 8;
|
||||||
@@ -1798,8 +1810,8 @@ Output::output_lookup_function_body (const Output_Compare& comparison) const
|
|||||||
indent, "");
|
indent, "");
|
||||||
printf ("%*s wordptr++;\n"
|
printf ("%*s wordptr++;\n"
|
||||||
"%*s }\n"
|
"%*s }\n"
|
||||||
"%*s return 0;\n",
|
"%*s return %s;\n",
|
||||||
indent, "", indent, "", indent, "");
|
indent, "", indent, "", indent, "", null_expression);
|
||||||
}
|
}
|
||||||
printf (" compare:\n");
|
printf (" compare:\n");
|
||||||
if (option[TYPE])
|
if (option[TYPE])
|
||||||
@@ -2020,7 +2032,10 @@ Output::output_lookup_function_body (const Output_Compare& comparison) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf (" }\n"
|
printf (" }\n"
|
||||||
" return 0;\n");
|
" return %s;\n",
|
||||||
|
null_expression);
|
||||||
|
|
||||||
|
delete[] null_expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generates C code for the lookup function. */
|
/* Generates C code for the lookup function. */
|
||||||
|
|||||||
@@ -219,5 +219,5 @@ is_reserved_word (str, len)
|
|||||||
return &wordlist[key];
|
return &wordlist[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (struct resword *) 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1878,6 +1878,6 @@ in_word_set (register const char *str, register size_t len)
|
|||||||
return &wordlist[key];
|
return &wordlist[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (struct charset *) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1550,7 +1550,7 @@ in_word_set (str, len)
|
|||||||
resword = &wordlist[299];
|
resword = &wordlist[299];
|
||||||
goto compare;
|
goto compare;
|
||||||
}
|
}
|
||||||
return 0;
|
return (struct resword *) 0;
|
||||||
compare:
|
compare:
|
||||||
{
|
{
|
||||||
register const char *s = resword->name;
|
register const char *s = resword->name;
|
||||||
@@ -1560,5 +1560,5 @@ in_word_set (str, len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (struct resword *) 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,5 +269,5 @@ is_reserved_word (str, len)
|
|||||||
return &wordlist[key];
|
return &wordlist[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (struct resword *) 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,5 +153,5 @@ is_reserved_word (register const char *str, register size_t len)
|
|||||||
return &wordlist[key];
|
return &wordlist[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (struct resword *) 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,5 +121,5 @@ in_word_set (register const char *str, register size_t len)
|
|||||||
return &wordlist[key];
|
return &wordlist[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (struct month *) 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,5 +199,5 @@ java_keyword (str, len)
|
|||||||
return &wordlist[key];
|
return &wordlist[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (struct java_keyword *) 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1495,7 +1495,7 @@ in_word_set (register const char *str, register size_t len)
|
|||||||
return &wordlist[key];
|
return &wordlist[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (struct language *) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -246,5 +246,5 @@ in_word_set (register const char *str, register size_t len)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (const char *) 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,5 +194,5 @@ is_reserved_word (register const char *str, register size_t len)
|
|||||||
return &wordlist[key];
|
return &wordlist[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (struct resword *) 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,5 +104,5 @@ in_word_set (register const char *str, register size_t len)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (const char *) 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,5 +104,5 @@ in_word_set (register const char *str, register size_t len)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (const char *) 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,5 +153,5 @@ in_word_set (register const char *str, register size_t len)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (const char *) 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,5 +230,5 @@ in_word_set (register const char *str, register size_t len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return (struct resword *) 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user