mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
Avoid compiler warnings
At least GCC 7.3, with -O1 or -O2 (but not -O0 or -O3) generates warnings with -Wnull-dereference when using yyformat: it fails to see yyformat cannot be null. Reported by Frank Heckenbach, https://savannah.gnu.org/patch/?9620. * configure.ac: Use -Wnull-dereference if supported. * data/glr.c, data/lalr1.cc, data/yacc.c: Define yyformat in such a way that GCC cannot not see that yyformat is defined. Using `default: abort();` also addresses the issue, but forces the inclusion of `stdlib.h`, which we avoid.
This commit is contained in:
@@ -82,7 +82,7 @@ AC_ARG_ENABLE([gcc-warnings],
|
||||
AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
|
||||
if test "$enable_gcc_warnings" = yes; then
|
||||
warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align -Wdocumentation
|
||||
-Wformat -Wpointer-arith -Wwrite-strings'
|
||||
-Wformat -Wnull-dereference -Wpointer-arith -Wwrite-strings'
|
||||
warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
|
||||
warn_cxx='-Wnoexcept'
|
||||
# Warnings for the test suite only.
|
||||
|
||||
@@ -2086,6 +2086,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
case N: \
|
||||
yyformat = S; \
|
||||
break
|
||||
default: /* Avoid compiler warnings. */
|
||||
YYCASE_(0, YY_("syntax error"));
|
||||
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
||||
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
|
||||
|
||||
@@ -1077,6 +1077,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
|
||||
case N: \
|
||||
yyformat = S; \
|
||||
break
|
||||
default: // Avoid compiler warnings.
|
||||
YYCASE_ (0, YY_("syntax error"));
|
||||
YYCASE_ (1, YY_("syntax error, unexpected %s"));
|
||||
YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s"));
|
||||
|
||||
@@ -1207,6 +1207,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
case N: \
|
||||
yyformat = S; \
|
||||
break
|
||||
default: /* Avoid compiler warnings. */
|
||||
YYCASE_(0, YY_("syntax error"));
|
||||
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
||||
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
|
||||
|
||||
Reference in New Issue
Block a user