bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: master: work around GCC warnings on Flex code


From: Akim Demaille
Subject: FYI: master: work around GCC warnings on Flex code
Date: Wed, 15 Aug 2018 14:43:23 +0200

I installed this in Bison’s master branch.

commit ef98967ada3c1cd48c177d7349e65a709bb49b97
Author: Akim Demaille <address@hidden>
Date:   Wed Aug 15 13:49:01 2018 +0200

    build: work around GCC warnings on Flex code
    
    With GCC 7.3.0 and Flex 2.6.4, we get warnings on all the generated
    scanners:
    
        examples/calc++/calc++-scanner.cc: In function 'void yyrestart(FILE*)':
        examples/calc++/calc++-scanner.cc:1611:20: error: potential null 
pointer dereference [-Werror=null-dereference]
         /* %endif */
          ~~~~~~~~~~~       ^
        examples/calc++/calc++-scanner.cc:1607:19: error: potential null 
pointer dereference [-Werror=null-dereference]
         /* %if-c-only */
          ~~~~~~~~~~~~~~~  ^
        examples/calc++/calc++-scanner.cc:1611:20: error: potential null 
pointer dereference [-Werror=null-dereference]
         /* %endif */
          ~~~~~~~~~~~       ^
        examples/calc++/calc++-scanner.cc:1607:19: error: potential null 
pointer dereference [-Werror=null-dereference]
         /* %if-c-only */
          ~~~~~~~~~~~~~~~  ^
        cc1plus: all warnings being treated as errors
    
    Obviously the lines are incorrect, and the warnings are emitted twice.
    Still, let's get rid of these warnings.
    
    * doc/bison.texi, src/flex-scanner.h: Disable these warnings in code
    generated by Flex.

diff --git a/doc/bison.texi b/doc/bison.texi
index 9f16f730..2882506b 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -11399,6 +11399,12 @@ parser's to get the set of defined tokens.
 # undef yywrap
 # 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__
+# pragma GCC diagnostic ignored "-Wnull-dereference"
+#endif
+
 // The location of the current token.
 static yy::location loc;
 address@hidden
diff --git a/src/flex-scanner.h b/src/flex-scanner.h
index 4dec7e1f..e09a1c04 100644
--- a/src/flex-scanner.h
+++ b/src/flex-scanner.h
@@ -44,6 +44,20 @@ 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
+// 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__ && 7 <= __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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]