mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
c, c++: avoid implicit fall-throw
Reported by Derek Clegg. http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00004.html * configure.ac (warn_common): Add -Wimplicit-fallthrough. This does trigger failures in the test suite. * data/skeletons/glr.c, data/skeletons/lalr1.cc, * data/skeletons/yacc.c, tests/c++.at: Make fall-throws explicit.
This commit is contained in:
@@ -96,7 +96,8 @@ 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
|
||||
-fparse-all-comments -Wdocumentation
|
||||
-Wformat -Wnull-dereference -Wpointer-arith -Wshadow
|
||||
-Wformat -Wimplicit-fallthrough -Wnull-dereference
|
||||
-Wpointer-arith -Wshadow
|
||||
-Wundefined-func-template -Wwrite-strings'
|
||||
warn_c='-Wbad-function-cast -Wstrict-prototypes'
|
||||
warn_cxx='-Wextra-semi -Wnoexcept'
|
||||
|
||||
@@ -590,7 +590,10 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
case '\\':
|
||||
if (*++yyp != '\\')
|
||||
goto do_not_strip_quotes;
|
||||
/* Fall through. */
|
||||
else
|
||||
goto append;
|
||||
|
||||
append:
|
||||
default:
|
||||
if (yyres)
|
||||
yyres[yyn] = *yyp;
|
||||
|
||||
@@ -532,7 +532,10 @@ m4_if(b4_prefix, [yy], [],
|
||||
case '\\':
|
||||
if (*++yyp != '\\')
|
||||
goto do_not_strip_quotes;
|
||||
// Fall through.
|
||||
else
|
||||
goto append;
|
||||
|
||||
append:
|
||||
default:
|
||||
yyr += *yyp;
|
||||
break;
|
||||
|
||||
@@ -1066,7 +1066,10 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
case '\\':
|
||||
if (*++yyp != '\\')
|
||||
goto do_not_strip_quotes;
|
||||
/* Fall through. */
|
||||
else
|
||||
goto append;
|
||||
|
||||
append:
|
||||
default:
|
||||
if (yyres)
|
||||
yyres[yyn] = *yyp;
|
||||
|
||||
@@ -6650,6 +6650,28 @@ For example, if you use @samp{%define api.prefix @{c@}}, the names become
|
||||
@code{cparse}, @code{clex}, @dots{}, @code{CSTYPE}, @code{CLTYPE}, and so
|
||||
on.
|
||||
|
||||
Users of Flex must update the signature of the generated @code{yylex}
|
||||
function. Since the Flex scanner usually includes the generated header of
|
||||
the parser (to get the definitions of the tokens, etc.), the most convenient
|
||||
way is to insert the declaration of @code{yylex} in the @code{provides}
|
||||
section:
|
||||
|
||||
@example
|
||||
%define api.prefix @{c@}
|
||||
// Emitted in the header file, after the definition of YYSTYPE.
|
||||
%code provides
|
||||
@{
|
||||
// Tell Flex the expected prototype of yylex.
|
||||
#define YY_DECL \
|
||||
int clex (CSTYPE*y ylval, CLTYPE *yylloc)
|
||||
|
||||
// Declare the scanner.
|
||||
YY_DECL;
|
||||
@}
|
||||
@end example
|
||||
|
||||
@sp 1
|
||||
|
||||
The @code{%define} variable @code{api.prefix} works in two different ways.
|
||||
In the implementation file, it works by adding macro definitions to the
|
||||
beginning of the parser implementation file, defining @code{yyparse} as
|
||||
|
||||
@@ -1242,7 +1242,8 @@ yylex (yy::parser::semantic_type *lvalp)
|
||||
default:
|
||||
lvalp->]AT_VARIANT_IF([build<Object> (res)],
|
||||
[obj = new Object (res)])[;
|
||||
// Fall through.
|
||||
goto zero;
|
||||
zero:
|
||||
case 0:
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user