From ea0db44fedc8d5cbdc5c3180bef0285d7ae83803 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 8 Sep 2018 06:47:08 +0200 Subject: [PATCH] build: work around warnings in Flex 2.5.35 That's the version on Ubuntu Precise. See also 1dac131ec45ffa1e382319a94640c65bd10f6aa5. * src/flex-scanner.h: Disable -Wdocumentation. * doc/bison.texi: Turn off a warning triggered by Flex 2.6.4. --- doc/bison.texi | 4 ++-- src/flex-scanner.h | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/doc/bison.texi b/doc/bison.texi index b7945343..55e2b46f 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -11426,8 +11426,8 @@ parser's to get the set of defined tokens. # define yywrap() 1 // Pacify warnings in yy_init_buffer (observed with Flex 2.6.4) -// and GCC 7.3.0. -#if defined __GNUC__ && 7 <= __GNUC__ +// and GCC 6.4.0, 7.3.0. +#if defined __GNUC__ && !defined __clang__ && 6 <= __GNUC__ # pragma GCC diagnostic ignored "-Wnull-dereference" #endif %@} diff --git a/src/flex-scanner.h b/src/flex-scanner.h index ac3b7338..66b6098e 100644 --- a/src/flex-scanner.h +++ b/src/flex-scanner.h @@ -27,6 +27,32 @@ + (YY_FLEX_MINOR_VERSION) * 1000 \ + (YY_FLEX_SUBMINOR_VERSION)) +// Pacify warnings in yy_init_buffer (observed with Flex 2.6.4 and GCC +// 6.4.0 and 7.3.0). +// +// ./src/scan-skel.c: In function 'skel_restart': +// ./src/scan-skel.c:2035:20: error: potential null pointer dereference [-Werror=null-dereference] +// b->yy_fill_buffer = 1; +// ~~~~~~~~~~~~~~~~~~^~~ +// ./src/scan-skel.c:2031:19: error: potential null pointer dereference [-Werror=null-dereference] +// b->yy_input_file = file; +// ~~~~~~~~~~~~~~~~~^~~~~~ +#if defined __GNUC__ && ! defined __clang__ && 6 <= __GNUC__ +# pragma GCC diagnostic ignored "-Wnull-dereference" +#endif + +// Old versions of Flex (2.5.35) generate an incomplete documentation comment. +// +// In file included from src/scan-code-c.c:3: +// src/scan-code.c:2198:21: error: empty paragraph passed to '@param' command +// [-Werror,-Wdocumentation] +// * @param line_number +// ~~~~~~~~~~~~~~~~~^ +// 1 error generated. +#if FLEX_VERSION <= 20060000 && defined __clang__ +# pragma clang diagnostic ignored "-Wdocumentation" +#endif + /* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */ #if FLEX_VERSION <= 2005031 int FLEX_PREFIX (get_lineno) (void); @@ -44,20 +70,6 @@ int FLEX_PREFIX (lex_destroy) (void); #define last_string FLEX_PREFIX (last_string) -// Pacify warnings in yy_init_buffer (observed with Flex 2.6.4 and GCC -// 6.4.0 and 7.3.0). -// -// ./src/scan-skel.c: In function 'skel_restart': -// ./src/scan-skel.c:2035:20: error: potential null pointer dereference [-Werror=null-dereference] -// b->yy_fill_buffer = 1; -// ~~~~~~~~~~~~~~~~~~^~~ -// ./src/scan-skel.c:2031:19: error: potential null pointer dereference [-Werror=null-dereference] -// b->yy_input_file = file; -// ~~~~~~~~~~~~~~~~~^~~~~~ -#if defined __GNUC__ && 6 <= __GNUC__ -# pragma GCC diagnostic ignored "-Wnull-dereference" -#endif - /* It seems to be a nice "feature" of Flex that one cannot use yytext, yyleng etc. when a prefix is given, since there is no longer a #define, but rather the token is actually changed in the output.