diff libinterp/parse-tree/lex.ll @ 21023:ec532a439c6f

rework method of disabling warnings from GCC * configure.ac: Check for GCC's #pragma GCC diagnostic feature. * libinterp/module.mk, libinterp/corefcn/module.mk, libinterp/parse-tree/module.mk: Eliminate separate libraries for TeX and Octave parsers. * oct-tex-lexer.in.ll, oct-tex-parser.in.yy, lex.ll, oct-parse.in.yy: Use GCC #pragma GCC diagnostic feature to more selectively disable warnings in generated code. * libgui/module.mk (rcc-command): Use GCC #pragma GCC diagnostic feature to more selectively disable warnings in generated code.
author John W. Eaton <jwe@octave.org>
date Thu, 31 Dec 2015 17:06:36 -0500
parents 9db35d2042be
children 5e00ed38a58b
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll	Thu Dec 31 13:45:43 2015 -0500
+++ b/libinterp/parse-tree/lex.ll	Thu Dec 31 17:06:36 2015 -0500
@@ -31,6 +31,24 @@
 object) relevant global values before and after the nested call.
 */
 
+%top {
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
+// This one needs to be global.
+#pragma GCC diagnostic ignored "-Wunused-function"
+
+// Disable this warning for code that is generated by flex, including
+// pattern rules.  Push the current state so we can restore the warning
+// state prior to functions we define at the bottom of the file.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
+#endif
+
+}
+
 %option prefix = "octave_"
 %option noyywrap
 %option reentrant
@@ -40,13 +58,6 @@
 %option noyyrealloc
 %option noyyfree
 
-%top {
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-}
-
 %x COMMAND_START
 %s MATRIX_START
 
@@ -1723,8 +1734,29 @@
       }
   }
 
+%{
+#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
+// Disable this warning for code that is generated by flex.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
+#endif
+%}
+
+%{
+#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
+// Also disable this warning for functions that is generated by flex
+// after the pattern rules.
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+%}
+
 %%
 
+#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
+// Restore prevailing warning state for remainder of the file.
+#pragma GCC diagnostic pop
+#endif
+
 void *
 octave_alloc (yy_size_t size, yyscan_t)
 {
@@ -2711,7 +2743,7 @@
     {
       uint64_t ivalue = 0;
 
-      for (int i = 0; i < strlen (tmptxt); i++)
+      for (size_t i = 0; i < strlen (tmptxt); i++)
         {
           ivalue <<= 1;
           ivalue += static_cast<uint64_t> (tmptxt[i] == '1');