changeset 24387:268d31e7aa4f

build: Silence compile warning about unknown GCC warning "-Wimplicit-fallthrough". * configure.ac: Check that compiler accepts "-Wimplicit-fallthrough" option. AC_DEFINE HAVE_WARNING_IMPLICIT_FALLTHROUGH if option is available. * lex.ll: Wrap "#pragma GCC diagnostic" code that uses "-Wimplicit-fallthrough" with "#if defined (HAVE_WARNING_IMPLICIT_FALLTHROUGH)"/"#endif".
author Rik <rik@octave.org>
date Thu, 07 Dec 2017 13:47:55 -0800
parents a164fd6e7e7b
children 206ef5cb8b16
files configure.ac libinterp/parse-tree/lex.ll
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Thu Dec 07 15:40:43 2017 -0500
+++ b/configure.ac	Thu Dec 07 13:47:55 2017 -0800
@@ -2929,7 +2929,14 @@
 
 if test $octave_cv_gcc_has_pragma_GCC_diagnostic = yes; then
   AC_DEFINE(HAVE_PRAGMA_GCC_DIAGNOSTIC, 1,
-   [define if GCC supports @%:@pragma GCC diagnostic ...])
+    [define if GCC supports @%:@pragma GCC diagnostic ...])
+fi
+
+## Check for one unusual warning used in pragmas that is not always available
+if test $octave_cv_gcc_has_pragma_GCC_diagnostic = yes; then
+  OCTAVE_CC_FLAG([-Wimplicit-fallthrough],
+    [AC_DEFINE(HAVE_WARN_IMPLICIT_FALLTHROUGH, 1,
+      [define if GCC supports -Wimplicit-fallthrough warning])])
 fi
 
 ### These are recommended by the gnulib bootstrap script:
--- a/libinterp/parse-tree/lex.ll	Thu Dec 07 15:40:43 2017 -0500
+++ b/libinterp/parse-tree/lex.ll	Thu Dec 07 13:47:55 2017 -0800
@@ -47,7 +47,9 @@
 #pragma GCC diagnostic ignored "-Wold-style-cast"
 #pragma GCC diagnostic ignored "-Wsign-compare"
 #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
-#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#if defined (HAVE_WARNING_IMPLICIT_FALLTHROUGH)
+#  pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#endif
 
 #endif