Re: manywarnings: Fix for compilers that are named '$host-gcc'

Bruno Haible via Gnulib discussion list <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <3703570.iIbC2pHGDl@cagnes>
On 2026-06-25 I wrote:
> The problem is that manywarnings.m4 understands only gcc binaries installed
> under the name "gcc" or "gcc-<version>" or something like that. This patch
> fixes it.
> 
> 
> 2026-06-25  Bruno Haible  <[email protected]>
> 
> 	manywarnings: Fix for compilers that are named '$host-gcc'.
> 	* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC(C)): Use only the first line
> 	of `$CC --version`. Allow $CC to be of the form '$host-gcc'.

Well, it fixed it for gcc versions < 10. With a mingw gcc version 13 or 14,
I still see a warning

 cc1: warning: command-line option '-Wzero-as-null-pointer-constant' is valid for C++/ObjC++ but not for C

This patch completes the fix.


2026-07-08  Bruno Haible  <[email protected]>

	manywarnings: Fix for compilers that are named '$host-gcc', part 2.
	* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC(C)): Apply the fix for
	-Wuseless-cast and -Wzero-as-null-pointer-constant also for GCC >= 10.

diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
index 6b323ba01d..02a2211201 100644
--- a/m4/manywarnings.m4
+++ b/m4/manywarnings.m4
@@ -1,5 +1,5 @@
 # manywarnings.m4
-# serial 36
+# serial 37
 dnl Copyright (C) 2008-2026 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -186,7 +186,8 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C
         ;;
     esac
     case $gl_gcc_version in
-      *gcc*' ('*') '?.* | gcc*' ('*') '1[[0-3]].*)
+      *gcc*' ('*') '[[0-9]].* | \
+      *gcc*' ('*') '1[[0-3]].*)
         # In GCC < 14 the option either does not exist,
         # or is accepted but always warns.
         ;;
@@ -195,7 +196,8 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C
         ;;
     esac
     case $gl_gcc_version in
-      *gcc*' ('*') '?.* | gcc*' ('*') '1[[0-4]].*)
+      *gcc*' ('*') '[[0-9]].* | \
+      *gcc*' ('*') '1[[0-4]].*)
         # In GCC < 15 the option either does not exist,
         # or is accepted but always warns.
         ;;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.