configure: Enable GCC warnings to report use of C2x features.
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 5 Jul 2021 20:46:32 +0000 (13:46 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 5 Jul 2021 20:49:28 +0000 (13:49 -0700)
One C2x feature in GCC 11 is the reason that the previous commit
afda22462a88 ("Fix broken build due to missing braces") was needed by
some developers.

Makefile.am
acinclude.m4
configure.ac

index 5967656765c580e84dfe9554036ad2a48f7596af..8b44e82efcd760cfbd17ac186e088339494b3d8e 100644 (file)
@@ -30,12 +30,7 @@ AM_CPPFLAGS = \
 
 AM_V_P ?= :
 
-AM_CFLAGS=
-
-if cc_is_gcc
-AM_CFLAGS+=-Wall -Wextra -Wwrite-strings -Wstrict-prototypes \
--Wpointer-arith -Wno-sign-compare -Wmissing-prototypes
-endif
+AM_CFLAGS=$(WARNING_FLAGS)
 
 pkgsysconfdir = $(sysconfdir)/$(PACKAGE)
 
index c1c67119aad1f12f759a0648df7edeaea9960bf3..e7dd390d6917babdf7743cda447829d8af8fa973 100644 (file)
@@ -66,6 +66,30 @@ AC_DEFUN([PSPP_CHECK_CC_OPTION],
   fi
 ])
 
+# PSPP_ENABLE_OPTION comes from Open vSwitch:
+# ----------------------------------------------------------------------
+# Copyright (c) 2007-2017 Nicira, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+dnl PSPP_ENABLE_OPTION([OPTION])
+dnl Check whether the given C compiler OPTION is accepted.
+dnl If so, add it to WARNING_FLAGS.
+dnl Example: PSPP_ENABLE_OPTION([-Wdeclaration-after-statement])
+AC_DEFUN([PSPP_ENABLE_OPTION],
+  [PSPP_CHECK_CC_OPTION([$1], [WARNING_FLAGS="$WARNING_FLAGS $1"])
+   AC_SUBST([WARNING_FLAGS])])
+# ----------------------------------------------------------------------
+
 dnl Check for readline and history libraries.
 
 dnl Modified for PSPP, based on readline.m4 serial 3 from
index 28f70cfacab63aa96e60434d1f7a51678e319b10..dfc4baf60c72d3fb98202a19872795635f93b008 100644 (file)
@@ -52,6 +52,14 @@ PSPP_CHECK_MAKEINFO_DOCBOOK_XML
 PSPP_CHECK_DOT
 
 PSPP_ENABLE_WERROR
+PSPP_ENABLE_OPTION([-Wall])
+PSPP_ENABLE_OPTION([-Wextra])
+PSPP_ENABLE_OPTION([-Wwrite-strings])
+PSPP_ENABLE_OPTION([-Wstrict-prototypes])
+PSPP_ENABLE_OPTION([-Wpointer-arith])
+PSPP_ENABLE_OPTION([-Wno-sign-compare])
+PSPP_ENABLE_OPTION([-Wmissing-prototypes])
+PSPP_ENABLE_OPTION([-Wc11-c2x-compat])
 
 AM_CONDITIONAL(cc_is_gcc, test x"$GCC" = x"yes" )
 AM_CONDITIONAL(host_is_w32, [case $host_os in mingw*) true;; *) false;; esac] )