From: Ben Pfaff Date: Mon, 5 Jul 2021 20:46:32 +0000 (-0700) Subject: configure: Enable GCC warnings to report use of C2x features. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08588e75a1df413eff334c30d62a93d04cb214cf;p=pspp configure: Enable GCC warnings to report use of C2x features. 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. --- diff --git a/Makefile.am b/Makefile.am index 5967656765..8b44e82efc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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) diff --git a/acinclude.m4 b/acinclude.m4 index c1c67119aa..e7dd390d69 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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 diff --git a/configure.ac b/configure.ac index 28f70cfaca..dfc4baf60c 100644 --- a/configure.ac +++ b/configure.ac @@ -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] )