diff --git a/configure.ac b/configure.ac index b7ba45dc..23aeb86d 100644 --- a/configure.ac +++ b/configure.ac @@ -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' diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c index bc491d51..87f2830b 100644 --- a/data/skeletons/glr.c +++ b/data/skeletons/glr.c @@ -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; diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc index f3ad181c..053ba3be 100644 --- a/data/skeletons/lalr1.cc +++ b/data/skeletons/lalr1.cc @@ -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; diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c index e78700f4..54e40e67 100644 --- a/data/skeletons/yacc.c +++ b/data/skeletons/yacc.c @@ -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; diff --git a/doc/bison.texi b/doc/bison.texi index c66a9746..5a724a98 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -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 diff --git a/tests/c++.at b/tests/c++.at index 215c032c..bb1d0dab 100644 --- a/tests/c++.at +++ b/tests/c++.at @@ -1242,7 +1242,8 @@ yylex (yy::parser::semantic_type *lvalp) default: lvalp->]AT_VARIANT_IF([build (res)], [obj = new Object (res)])[; - // Fall through. + goto zero; + zero: case 0: return res; }