]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
build: Take advantage of gcc warning options not included in -Wall.
authorBruno Haible <bruno@clisp.org>
Fri, 2 Jun 2023 23:34:14 +0000 (01:34 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 4 Jun 2023 18:04:25 +0000 (20:04 +0200)
* autogen.sh (GNULIB_MODULES_RUNTIME_OTHER, GNULIB_MODULES_LIBINTL,
GNULIB_MODULES_LIBASPRINTF, GNULIB_MODULES_TOOLS_OTHER): Add manywarnings.
* m4/more-warnings.m4: New file.

* libtextstyle/autogen.sh (GNULIB_MODULES): Add manywarnings.
Copy also more-warnings.m4.
* gnulib-local/modules/libxml (Makefile.am): New variable libxml_rpl_la_CFLAGS.
* libtextstyle/gnulib-local/modules/libcroco (Makefile.am): New variable
libcroco_rpl_la_CFLAGS.
* libtextstyle/gnulib-local/modules/libglib (Makefile.am): New variable
libglib_rpl_la_CFLAGS.
* libtextstyle/configure.ac: Invoke gt_MORE_WARNINGS, gl_CC_INHIBIT_WARNINGS.
* libtextstyle/lib/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
(config.h): Do the compilations with GL_CFLAG_INHIBIT_WARNINGS.

* gettext-runtime/configure.ac: Invoke gt_MORE_WARNINGS.
* gettext-runtime/src/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gnulib-local/modules/gettext-runtime-misc (Makefile.am): Add WARN_CFLAGS to
AM_CFLAGS.

* gettext-runtime/intl/configure.ac: Invoke gt_MORE_WARNINGS.
* gettext-runtime/intl/Makefile.am (AM_CFLAGS): Add WARN_CFLAGS.
* gnulib-local/modules/gettext-runtime-intl-misc (Makefile.am): Add WARN_CFLAGS
to AM_CFLAGS.

* gettext-runtime/libasprintf/configure.ac: Invoke gt_MORE_WARNINGS.
* gettext-runtime/libasprintf/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.

* gettext-tools/configure.ac: Invoke gt_MORE_WARNINGS, gl_CC_INHIBIT_WARNINGS.
* gettext-tools/gnulib-lib/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gettext-tools/libgrep/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gettext-tools/src/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
* gettext-tools/libgettextpo/Makefile.am (AM_CFLAGS): Set to WARN_CFLAGS.
(config.h): Do the compilations with GL_CFLAG_INHIBIT_WARNINGS.

22 files changed:
autogen.sh
gettext-runtime/configure.ac
gettext-runtime/intl/Makefile.am
gettext-runtime/intl/configure.ac
gettext-runtime/libasprintf/Makefile.am
gettext-runtime/libasprintf/configure.ac
gettext-runtime/src/Makefile.am
gettext-tools/configure.ac
gettext-tools/gnulib-lib/Makefile.am
gettext-tools/libgettextpo/Makefile.am
gettext-tools/libgrep/Makefile.am
gettext-tools/src/Makefile.am
gnulib-local/modules/gettext-runtime-intl-misc
gnulib-local/modules/gettext-runtime-misc
gnulib-local/modules/libxml
libtextstyle/.gitignore
libtextstyle/autogen.sh
libtextstyle/configure.ac
libtextstyle/gnulib-local/modules/libcroco
libtextstyle/gnulib-local/modules/libglib
libtextstyle/lib/Makefile.am
m4/more-warnings.m4 [new file with mode: 0644]

index 44f9ad59e2f8b869a1bd465703e96d7a8a0f0f35..462a6b20713a464709f32be6c8ec1dcb42522068 100755 (executable)
@@ -102,6 +102,7 @@ if ! $skip_gnulib; then
     csharpcomp-script
     java
     javacomp-script
+    manywarnings
   '
   $GNULIB_TOOL --dir=gettext-runtime --lib=libgrt --source-base=gnulib-lib --m4-base=gnulib-m4 --no-libtool --local-dir=gnulib-local --local-symlink \
     --import $GNULIB_MODULES_RUNTIME_FOR_SRC $GNULIB_MODULES_RUNTIME_OTHER || exit $?
@@ -118,6 +119,7 @@ if ! $skip_gnulib; then
     localcharset
     localename
     lock
+    manywarnings
     relocatable-lib-lgpl
     tsearch
     vasnprintf-posix
@@ -129,6 +131,7 @@ if ! $skip_gnulib; then
   # In gettext-runtime/libasprintf:
   GNULIB_MODULES_LIBASPRINTF='
     alloca
+    manywarnings
     vasnprintf
   '
   $GNULIB_TOOL --dir=gettext-runtime/libasprintf --source-base=gnulib-lib --m4-base=gnulib-m4 --lgpl=2 --libtool --local-dir=gnulib-local --local-symlink \
@@ -289,6 +292,7 @@ if ! $skip_gnulib; then
     java
     javacomp-script
     javaexec-script
+    manywarnings
     stdint
   '
   GNULIB_MODULES_TOOLS_LIBUNISTRING_TESTS='
index 2006d47156680973d67d5a27b28ab06c733090c0..126d0690fd95fe9ed593e7c32e2f3b10394042f0 100644 (file)
@@ -1,5 +1,5 @@
 dnl Configuration for the gettext-runtime directory of GNU gettext
-dnl Copyright (C) 1995-2010, 2012-2015, 2018-2022 Free Software Foundation, Inc.
+dnl Copyright (C) 1995-2010, 2012-2015, 2018-2023 Free Software Foundation, Inc.
 dnl
 dnl This program is free software: you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
@@ -75,6 +75,8 @@ AM_PROG_CC_C_O
 
 dnl Check for build configuration.
 
+gt_MORE_WARNINGS
+
 gl_WOE32_DLL
 
 LT_INIT([win32-dll])
index bd1f0077d1c65e4a214ed4102e91980e4b97eb7e..f6d8f547bcb2d97e24c03387ddb4e870c486a38e 100644 (file)
@@ -46,13 +46,16 @@ if WOE32
 AM_CPPFLAGS += -D__USE_MINGW_ANSI_STDIO=0
 endif
 
+# Enable more warning options in this directory.
+AM_CFLAGS = @WARN_CFLAGS@
+
 BISON = @INTLBISON@
 BISONFLAGS = --name-prefix=__gettext
 # Just to shut up Automake "error: Yacc source seen but 'YACC' is undefined".
 YACC = $(BISON) -d
 
 # Tell the ELF linker which symbols to export.
-AM_CFLAGS = @CFLAG_VISIBILITY@
+AM_CFLAGS += @CFLAG_VISIBILITY@
 # Tell the mingw or Cygwin linker which symbols to export.
 if WOE32DLL
 AM_LDFLAGS = -Wl,--export-all-symbols
index 8da3390163d0c2921477629cedd2558b76e3d707..3005f63bbb95d69112740bd5569f2f64835e00ec 100644 (file)
@@ -51,6 +51,8 @@ gl_EARLY
 
 dnl Check for build configuration.
 
+gt_MORE_WARNINGS
+
 gl_WOE32_DLL
 
 LT_INIT([win32-dll])
index 592b6bf4404de233bb2a051b0e920d37dd225c0f..c0eb4062d3e2f25298263f4ac94fafc7ac4ae095 100644 (file)
@@ -1,5 +1,5 @@
 ## Makefile for the gettext-runtime/libasprintf subdirectory of GNU gettext
-## Copyright (C) 2002-2007, 2009-2011, 2013, 2016, 2018-2019, 2021 Free Software Foundation, Inc.
+## Copyright (C) 2002-2007, 2009-2011, 2013, 2016, 2018-2019, 2021, 2023 Free Software Foundation, Inc.
 ##
 ## This program is free software: you can redistribute it and/or modify
 ## it under the terms of the GNU Lesser General Public License as published by
@@ -41,6 +41,9 @@ if WOE32
 DEFS += -D__USE_MINGW_ANSI_STDIO=0
 endif
 
+# Enable more warning options in this directory.
+AM_CFLAGS = @WARN_CFLAGS@
+
 
 # Library include file.
 
index 0bcd4c311839f1b64b0716a4d1e1c6425a8b0ac1..2fe76cf0206f6e8a57e6c5a5501320bf6725a2d4 100644 (file)
@@ -1,5 +1,5 @@
 dnl Configuration for the GNU libasprintf library
-dnl Copyright (C) 2002-2012, 2016, 2018-2021 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2012, 2016, 2018-2023 Free Software Foundation, Inc.
 dnl
 dnl This program is free software: you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
@@ -43,6 +43,8 @@ gl_EARLY
 
 dnl Check for build configuration.
 
+gt_MORE_WARNINGS
+
 gl_WOE32_DLL
 
 LT_INIT([win32-dll])
index 1fa850745f0e497d79621eee7808b94be5920587..e9974c4c28fc43632b6a5dc81074d748c4cdc2c4 100644 (file)
@@ -33,6 +33,9 @@ AM_CPPFLAGS = \
   -I../gnulib-lib -I$(srcdir)/../gnulib-lib
 DEFS = -DLOCALEDIR=$(localedir_c_make) @DEFS@
 
+# Enable more warning options in this directory.
+AM_CFLAGS = @WARN_CFLAGS@
+
 # Source dependencies.
 gettext_SOURCES = gettext.c escapes.h
 ngettext_SOURCES = ngettext.c escapes.h
index 4d9bc8e5287f97fcf751f3428898a002e94d18cf..18ddcc312fe422b3d245c1d9ee40863438918abc 100644 (file)
@@ -92,6 +92,9 @@ gtpo_EARLY
 
 dnl Check for build configuration.
 
+gt_MORE_WARNINGS
+gl_CC_INHIBIT_WARNINGS
+
 gl_WOE32_DLL
 
 LT_INIT([win32-dll])
index 244c3acfa5d62a28a995fa1be3441ac2236dcd20..e9c517fe9d0945a6cae4f2aa3334f4f2f8ee6de0 100644 (file)
@@ -1,6 +1,5 @@
 ## Makefile for the gettext-tools/gnulib-lib subdirectory of GNU gettext
-## Copyright (C) 1995-1998, 2000-2006, 2009, 2016, 2019, 2021 Free Software
-## Foundation, Inc.
+## Copyright (C) 1995-1998, 2000-2006, 2009, 2016, 2019, 2021, 2023 Free Software Foundation, Inc.
 ##
 ## This program is free software: you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -52,6 +51,9 @@ if INCLUDED_LIBXML
 AM_CPPFLAGS += -DLIBXML_STATIC
 endif
 
+# Enable more warning options in this directory.
+AM_CFLAGS = @WARN_CFLAGS@
+
 # Rules generated and collected by gnulib-tool.
 include Makefile.gnulib
 
index ee9ed39c42a5ae423277990a148b510a6b15ebf7..798ae98f31181aa921b77d866800709e5f48de66 100644 (file)
@@ -42,6 +42,9 @@ AM_CPPFLAGS = \
 
 DEFS = -DIN_LIBGETTEXTPO=1 -DOMIT_SETLOCALE_LOCK=1 @DEFS@
 
+# Enable more warning options in this directory.
+AM_CFLAGS = @WARN_CFLAGS@
+
 # libgettextpo contains the public API for PO files.
 libgettextpo_la_SOURCES = \
   gettext-po.c \
@@ -177,7 +180,7 @@ config.h: $(BUILT_SOURCES)
                  sf=`echo "$$f" | sed -e 's,\\.[^.]*$$,,'`.c; \
                  test -f $$sf || sf=$(srcdir)/$$sf; \
                  of=`echo "$$f" | sed -e 's,^.*/,,' -e 's,\\.[^.]*$$,,'`.$(OBJEXT); \
-                 $(COMPILE) $(DEFS) -c $$sf || { rm -f config.h; exit 1; }; \
+                 $(COMPILE) $(DEFS) $(GL_CFLAG_INHIBIT_WARNINGS) -c $$sf || { rm -f config.h; exit 1; }; \
                  sh ./exported.sh $$of 1>&5; \
                  rm -f $$of `echo "$$of" | sed -e 's,\\.$(OBJEXT)$$,.lo,'`; \
                  ;; \
index 37393a2a35ca5eaceaf91a0c25bc37f588681b35..ea5e4f5d0273795a8f7c44b9b2d0425f27ca45c2 100644 (file)
@@ -1,5 +1,5 @@
 ## Makefile for libgrep directory in GNU gettext package.
-## Copyright (C) 2005-2007, 2009-2010, 2014, 2021 Free Software Foundation, Inc.
+## Copyright (C) 2005-2007, 2009-2010, 2014, 2021, 2023 Free Software Foundation, Inc.
 ##
 ## This program is free software: you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -29,6 +29,9 @@ noinst_LIBRARIES =
 
 AM_CPPFLAGS = -I.. -I../gnulib-lib -I$(top_srcdir)/gnulib-lib -I../../gettext-runtime/intl
 
+# Enable more warning options in this directory.
+AM_CFLAGS = @WARN_CFLAGS@
+
 # Rules generated and collected by gnulib-tool, for building libgrep.a.
 include Makefile.gnulib
 
index ad495ec96f62567cda3c2c3616b9e1437a3276d1..fc3ae26233b52a091adc355efe18bc1556413308 100644 (file)
@@ -105,6 +105,10 @@ DEFS = \
   -DGETTEXTDATADIR=\"$(pkgdatadir)\" \
   -DPROJECTSDIR=\"$(projectsdir)\" \
   -DEXEEXT=\"@EXEEXT@\" @DEFS@
+
+# Enable more warning options in this directory.
+AM_CFLAGS = @WARN_CFLAGS@
+
 # Ensure that <stdint.h> defines SIZE_MAX in C++ mode, like it does in C mode.
 AM_CXXFLAGS = -D__STDC_LIMIT_MACROS
 
index 671b5f6e9c557016152b8df04f74a1fa018606b3..59738717a1ecb8035c42d4bef20bbd3ff3c3b85a 100644 (file)
@@ -17,6 +17,9 @@ AM_CPPFLAGS += \
   -Dset_relocation_prefix=libintl_set_relocation_prefix \
   -DDEPENDS_ON_LIBICONV=1
 
+# Enable more warning options in this directory.
+AM_CFLAGS += @WARN_CFLAGS@
+
 # Support building libintl.a with -fPIC (needed by GCC).
 AM_CFLAGS += @PICFLAG@
 
index 4cad86d658484c49b8d94ed8ea3282f381db3269..470b7250cccddee3869efd705a02bdae5ce29046 100644 (file)
@@ -15,6 +15,9 @@ AM_CPPFLAGS += -I$(top_builddir)/intl -I$(top_srcdir)/intl
 # Parametrization of the 'relocatable' module.
 AM_CPPFLAGS += -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1
 
+# Enable more warning options in this directory.
+AM_CFLAGS += @WARN_CFLAGS@
+
 Include:
 
 License:
index 9488095747d970e06280d2e1f8902bcf450431ad..a722b30965194be0c937f8e4c679d6677c99e019 100644 (file)
@@ -178,6 +178,10 @@ libxml_rpl_la_SOURCES = \
   libxml/xpath.c \
   libxml/xpointer.c
 libxml_rpl_la_CPPFLAGS = $(AM_CPPFLAGS) $(NO_CXX)
+# We need NO_EXPENSIVE_WARN_CFLAGS, because with gcc 13, the compilation of
+# libxml/parser.c requires 1.9 GB of RAM with -fanalyzer, as opposed to
+# 0.09 GB of RAM with -fno-analyzer.
+libxml_rpl_la_CFLAGS = @FOREIGN_WARN_CFLAGS@ @NO_EXPENSIVE_WARN_CFLAGS@
 
 BUILT_SOURCES += $(LIBXML_H)
 
index 1a84e7153103842f40696427856ac8e226ff7527..dad3bb540ba071ee16b823b1bb9b2399f1619b00 100644 (file)
 /m4/ltsugar.m4
 /m4/ltversion.m4
 /m4/lt~obsolete.m4
+/m4/more-warnings.m4
 /m4/woe32-dll.m4
 # Dummy ChangeLogs:
 /ChangeLog
index 291da4a62cdba83d9fb6d559fc494bdd84a67585..f271fa5c5f17649b79126ad47814ba2a5b7cfda1 100755 (executable)
@@ -6,7 +6,7 @@
 #
 # This script requires autoconf-2.64..2.71 and automake-1.11..1.16 in the PATH.
 
-# Copyright (C) 2003-2022 Free Software Foundation, Inc.
+# Copyright (C) 2003-2023 Free Software Foundation, Inc.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -78,6 +78,7 @@ if test $skip_gnulib = false; then
     filename
     isatty
     largefile
+    manywarnings
     vasprintf-posix
     xalloc
     xconcat-filename
@@ -108,6 +109,7 @@ cp -p ../INSTALL.windows .
 mkdir -p m4
 cp -p ../m4/libtool.m4 m4/
 cp -p ../m4/lt*.m4 m4/
+cp -p ../m4/more-warnings.m4 m4/
 cp -p ../m4/woe32-dll.m4 m4/
 cp -p ../build-aux/ltmain.sh build-aux/
 cp -p ../build-aux/texi2html build-aux/
index e79417d6a1312e16a5be90249308d7b3ce914c8f..55b9ef8f7544261f8fa5286e3d9c74c5b7dc99f3 100644 (file)
@@ -1,5 +1,5 @@
 dnl Configuration for the toplevel directory of GNU libtextstyle
-dnl Copyright (C) 2009-2021 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
 dnl
 dnl This program is free software: you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
@@ -50,6 +50,9 @@ AC_EXEEXT
 
 dnl Check for build configuration.
 
+gt_MORE_WARNINGS
+gl_CC_INHIBIT_WARNINGS
+
 gl_WOE32_DLL
 
 LT_INIT([win32-dll])
index 712a7a9ac798aeeb84d7fc1d4173c5b69973ae5c..a4b4c785bce401913f46193db84c6e863e134104 100644 (file)
@@ -117,6 +117,7 @@ libcroco_rpl_la_SOURCES = \
   libcroco/cr-token.c \
   libcroco/cr-utils.c
 libcroco_rpl_la_CPPFLAGS = $(AM_CPPFLAGS) $(NO_CXX)
+libcroco_rpl_la_CFLAGS = @FOREIGN_WARN_CFLAGS@
 
 if GL_COND_LIBTOOL
 lib_LDFLAGS += $(LTLIBCROCO)
index 776234e0c73beb5a32f209d6cfbc3baf4bc0af0e..1e80de5748704705e3e390796b7c1aeab7cbd218 100644 (file)
@@ -54,6 +54,7 @@ libglib_rpl_la_SOURCES = \
   glib/gstrfuncs.c \
   glib/gstring.c
 libglib_rpl_la_CPPFLAGS = $(AM_CPPFLAGS) $(NO_CXX)
+libglib_rpl_la_CFLAGS = @FOREIGN_WARN_CFLAGS@
 
 BUILT_SOURCES += $(LIBGLIB_H)
 
index 6bf636dc8369cc63e3880f95099c54fdd1ee6ef2..411a2e40154b80a63e4ffbe4ff0d34aed1d31019 100644 (file)
@@ -1,5 +1,5 @@
 ## Makefile for the lib subdirectory of GNU libtextstyle.
-## Copyright (C) 2009-2022 Free Software Foundation, Inc.
+## Copyright (C) 2009-2023 Free Software Foundation, Inc.
 ##
 ## This program is free software: you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -56,6 +56,9 @@ if WOE32
 AM_CPPFLAGS += -D__USE_MINGW_ANSI_STDIO=0
 endif
 
+# Enable more warning options in this directory.
+AM_CFLAGS = @WARN_CFLAGS@
+
 # Rules generated and collected by gnulib-tool.
 include Makefile.gnulib
 
@@ -227,8 +230,8 @@ config.h: $(BUILT_SOURCES) libtextstyle.sym
                    sf=`echo "$$f" | sed -e 's,\\.[^.]*$$,,'`.c; \
                    test -f $$sf || sf=$(srcdir)/$$sf; \
                    of=`echo "$$f" | sed -e 's,^.*/,,' -e 's,\\.[^.]*$$,,'`.$(OBJEXT); \
-                   echo "$(COMPILE) -c $$sf" 1>&6; \
-                   $(COMPILE) -c $$sf || { rm -f config.h; exit 1; }; \
+                   echo "$(COMPILE) $(GL_CFLAG_INHIBIT_WARNINGS) -c $$sf" 1>&6; \
+                   $(COMPILE) $(GL_CFLAG_INHIBIT_WARNINGS) -c $$sf || { rm -f config.h; exit 1; }; \
                    sh ./exported.sh $$of 1>&5; \
                    rm -f $$of `echo "$$of" | sed -e 's,\\.$(OBJEXT)$$,.lo,'`; \
                    ;; \
diff --git a/m4/more-warnings.m4 b/m4/more-warnings.m4
new file mode 100644 (file)
index 0000000..42c168b
--- /dev/null
@@ -0,0 +1,190 @@
+# more-warnings.m4 serial 1 (gettext-0.21.2)
+dnl Copyright (C) 2023 Free Software Foundation, Inc.
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License.  As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+
+dnl From Bruno Haible.
+
+dnl Use more compiler warnings, beyond '-Wall' (for gcc and clang).
+AC_DEFUN([gt_MORE_WARNINGS],
+[
+  AC_ARG_ENABLE([more-warnings],
+AS_HELP_STRING([[--enable-more-warnings]], [enable additional compiler warnings beyond -Wall])
+AS_HELP_STRING([[--disable-more-warnings]], [obey exactly the warning options specified in $CPPFLAGS $CFLAGS]),
+    [more_warnings=$enableval],
+    [dnl When to enable the warnings by default?
+     dnl Some other packages enable the warnings by default in a git checkout
+     dnl when there is no .tarball version file. This is too unreliable, since
+     dnl - Often the .tarball-version file is still present after the maintainer
+     dnl   made a release or prerelease.
+     dnl - It is useful to see the warnings also when doing portability testing,
+     dnl   that is, when building a tarball created by "make distcheck".
+     dnl Hence, use a different heuristic: Enable the warnings by default if
+     dnl the option -Wall is already specified.
+     case " $CC $CPPFLAGS $CFLAGS " in
+       *" -Wall "*) more_warnings=yes ;;
+       *)           more_warnings=no ;;
+     esac
+    ])
+
+  dnl Warning options for production code, not including tests.
+  WARN_CFLAGS=
+  dnl Warning options for production code imported from other packages
+  dnl (libglib, libxml, libcroco).
+  FOREIGN_WARN_CFLAGS=
+  dnl Warning options that turn off expensive processing in the compiler.
+  NO_EXPENSIVE_WARN_CFLAGS=
+  if test "x$more_warnings" = xyes; then
+    dnl Add warning options. But do *not* add options that change the
+    dnl generated code. (That's because this code here is also in effect
+    dnl for distro builds.)
+
+    dnl Set up the list of the pointless, undesired warnings.
+    nw=
+    dnl First, the warnings that are generated already with -O0:
+    dnl These warnings enforce a certain programming style that is not ours.
+    nw="$nw -Wempty-body"
+    nw="$nw -Wvla"
+    dnl All warnings produced by these options (in gcc 13) have been false
+    dnl alarms.
+    nw="$nw -Wanalyzer-double-fclose"
+    nw="$nw -Wanalyzer-double-free"
+    nw="$nw -Wanalyzer-fd-double-close"
+    nw="$nw -Wanalyzer-null-argument"
+    nw="$nw -Wanalyzer-null-dereference"
+    nw="$nw -Wanalyzer-use-of-uninitialized-value"
+    dnl This warning option is nonsense. It's normal to have to cast, for
+    dnl example, a 'double' to an 'int'. When that 'double' value is the
+    dnl result of a function call, this does not make the cast dangerous
+    dnl in any way.
+    nw="$nw -Wbad-function-cast"
+    dnl When we allocate memory for several objects through a single malloc()
+    dnl call, it's normal that we then have to cast a 'char *' to various
+    dnl pointer types with varying alignment.
+    nw="$nw -Wcast-align"
+    dnl We use computed format strings in a number of places, and glibc's
+    dnl <bits/error.h> does it as well.
+    nw="$nw -Wformat-nonliteral"
+    dnl We define a few functions for binary backward compatibility only.
+    dnl These functions are not declared on purpose: So that they cannot be
+    dnl accidentally used in new code.
+    nw="$nw -Wmissing-declarations"
+    nw="$nw -Wmissing-prototypes"
+    dnl We frequently have a static variable and a local variable in a function
+    dnl with the same name. This is normal, because the same concept often
+    dnl occurs in multiple locations in a file. Thus, ignore
+    dnl "... shadows a global declaration" warnings. Only
+    dnl "... shadows a parameter" and "... shadows a previous local" warnings
+    dnl are worth eliminating; see below.
+    nw="$nw -Wshadow"
+    dnl Too many warnings. We often use signed types like 'int' or 'idx_t'
+    dnl for counter variables, yet SIZEOF(array) is an unsigned value.
+    nw="$nw -Wsign-compare"
+    dnl This warning is based on older ISO C standards. It warns, in particular,
+    dnl about function definitions that are valid in ISO C 23 (static and
+    dnl non-static functions). Cf.
+    dnl https://lists.gnu.org/archive/html/bug-gnulib/2023-02/msg00055.html
+    dnl https://lore.kernel.org/distributions/2354211.7hzS34FegO@nimes/
+    nw="$nw -Wold-style-definition"
+    dnl This warning is based on older ISO C standards. It warns, in particular,
+    dnl about function definitions that are valid in ISO C 23 (static functions
+    dnl only). Cf.
+    dnl https://lists.gnu.org/archive/html/bug-gnulib/2023-02/msg00055.html
+    dnl https://lore.kernel.org/distributions/2354211.7hzS34FegO@nimes/
+    dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108690
+    nw="$nw -Wstrict-prototypes"
+    dnl There is no reason to warn about an abstract (unimplemented) method in
+    dnl an abstract class; it has no chance of ever being called. Only the
+    dnl implementations of the method on concrete subclasses can be called.
+    nw="$nw -Wsuggest-attribute=noreturn"
+    dnl There is no reason to warn about code that does not want to make
+    dnl assumptions about whether a certain type is signed or unsigned.
+    nw="$nw -Wtype-limits"
+    dnl Too many warnings. #if preprocessor directives often lead to unused
+    dnl macros.
+    nw="$nw -Wunused-macros"
+    dnl Unused parameters are frequent in functions that are meant to implement
+    dnl a given function type.
+    nw="$nw -Wunused-parameter"
+    dnl
+    dnl Next, the warnings that are generated with -O2:
+    dnl This warning option frequently produces false alarms.
+    dnl See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21161>.
+    nw="$nw -Wclobbered"
+    dnl I'm not interested in the details of which functions get inlined and
+    dnl which don't.
+    nw="$nw -Winline"
+    dnl Some of these warnings point to functions for which the result's
+    dnl destruction should be done through fclose(), <datatype>_free(), etc.,
+    dnl not free().
+    nw="$nw -Wsuggest-attribute=malloc"
+    dnl Too many warnings. It's ridiculous that the developer should spend
+    dnl brain cycles on things that the compiler could often infer and which
+    dnl have little effect on the performance of the generated code.
+    dnl Cf. <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109914>.
+    nw="$nw -Wsuggest-attribute=pure"
+    dnl Too many warnings. It's ridiculous that the developer should spend
+    dnl brain cycles on things that the compiler could often infer and which
+    dnl have little effect on the performance of the generated code.
+    dnl Cf. <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109915>.
+    nw="$nw -Wsuggest-attribute=const"
+    dnl It's ridiculous that the developer should spend brain cycles on things
+    dnl that the compiler could often infer and which have little effect on the
+    dnl performance of the generated code.
+    nw="$nw -Wsuggest-attribute=cold"
+
+    dnl Setup the list of meaningful warning options for the C compiler.
+    dnl The list comes from manywarnings.m4. Warning options that are not
+    dnl generally meaningful have already been filtered out (cf.
+    dnl build-aux/gcc-warning.spec).
+    gl_MANYWARN_ALL_GCC([possible_warning_options])
+
+    dnl Compute the list of warning options that are desired.
+    gl_MANYWARN_COMPLEMENT([desired_warning_options],
+                           [$possible_warning_options], [$nw])
+    dnl Compute the list of remaining undesired warning options.
+    dnl Namely those, that were not in manywarnings.m4 because they were
+    dnl already listed in build-aux/gcc-warning.spec; this includes those
+    dnl that are implied by -Wall.
+    gl_MANYWARN_COMPLEMENT([remaining_undesired_warning_options],
+                           [$nw], [$possible_warning_options])
+
+    dnl Add the desired warning options to WARN_CFLAGS.
+    for w in $desired_warning_options; do
+      gl_WARN_ADD([$w])
+    done
+
+    dnl Add the opposites of the remaining undesired warning options to
+    dnl WARN_CFLAGS.
+    for w in `echo "$remaining_undesired_warning_options" | sed -e 's/-W/-Wno-/g'`; do
+      gl_WARN_ADD([$w])
+    done
+
+    dnl Cf. -Wshadow, above.
+    gl_WARN_ADD([-Wshadow=local])
+
+    dnl For production code imported from other packages, disable some other
+    dnl warnings. For imported code, I want to minimize difference w.r.t.
+    dnl upstream.
+    FOREIGN_WARN_CFLAGS="$WARN_CFLAGS"
+    fnw=
+    fnw="$fnw -Wcast-function-type"
+    fnw="$fnw -Wduplicated-cond"
+    fnw="$fnw -Wformat"
+    fnw="$fnw -Wimplicit-fallthrough"
+    fnw="$fnw -Wnull-dereference"
+    fnw="$fnw -Wsuggest-attribute=format"
+    for w in `echo "$fnw" | sed -e 's/-W/-Wno-/g'`; do
+      gl_WARN_ADD([$w], [FOREIGN_WARN_CFLAGS])
+    done
+
+    dnl Warning options that turn off expensive processing in the compiler.
+    gl_WARN_ADD([-fno-analyzer], [NO_EXPENSIVE_WARN_CFLAGS])
+  fi
+  AC_SUBST([WARN_CFLAGS])
+  AC_SUBST([FOREIGN_WARN_CFLAGS])
+  AC_SUBST([NO_EXPENSIVE_WARN_CFLAGS])
+])