Paul Eggert wrote:
> > PS: An alternative fix of the problem is to change the body of 
> > AC_CHECK_FUNC,
> > instead of adding a compiler option.
> 
> Thanks, good idea.

Oops, unfortunately this idea does not work. The effect of the added
pragmas for _MSC_VER is merely to reduce the diagnostic output from

  conftest.c(30): warning C4391: 'char memcpy(void)': incorrect return type for 
intrinsic function, expected 'void'
  conftest.c(30): warning C4392: 'char memcpy(void)': incorrect number of 
arguments for intrinsic function, expected '3' arguments
  conftest.c(41): error C2168: 'memcpy': too few actual parameters for 
intrinsic function

to

  conftest.c(30): error C2040: 'memcpy': 'char (void)' differs in levels of 
indirection from 'void *()'

but that's still an error. I also tried different forms of the pragma;
doesn't help. The only way to make the error disappear is the '-Oi-' option.
Apologies. I should have tested that earlier.

> We can fix a similar glitch with recent Clang too.

This clang warning is only supported for clang >= 4. With clang version 3.0
I get:

  $ clang -Wall -S foo.c
  foo.c:1:35: warning: unknown warning group 
'-Wincompatible-library-redeclaration', ignored [-Wunknown-pragmas]
  # pragma clang diagnostic ignored "-Wincompatible-library-redeclaration"
                                    ^
  1 warning generated.

> I installed the attached to Autoconf.

I propose the additional attached patch.

Bruno


>From c545a30133bcf66d22e6548349ab4304c5001335 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Sun, 18 Oct 2026 22:01:52 +0200
Subject: [PATCH] Partially revert last AC_CHECK_FUNC change.

* lib/autoconf/c.m4 (AC_LANG_FUNC_LINK_TRY(C)): Limit the clang
workaround to clang >= 4. Revert the attempted MSVC workaround,
as it does not work.
---
 NEWS              | 4 ++--
 lib/autoconf/c.m4 | 8 +-------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/NEWS b/NEWS
index b5636f77..023880b3 100644
--- a/NEWS
+++ b/NEWS
@@ -27,10 +27,10 @@ GNU Autoconf NEWS - User visible changes.
 
 *** AC_C_RESTRICT no longer triggers -Wkeyword-macro warnings from GCC 16.
 
-*** AC_CHECK_FUNC and related macros now work better with Clang and MSVC.
+*** AC_CHECK_FUNC and related macros now work better with Clang.
 
   Arguments like CFLAGS="-Wno-incompatible-library-redeclaration" are
-  no longer needed when configuring with Clang, and similarly with MSVC.
+  no longer needed when configuring with Clang in pedantic mode.
 
 * Noteworthy changes in release 2.73 (2026-03-20) [release]
 
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 9d264b2a..8d9cfe64 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -165,16 +165,10 @@ m4_define([AC_LANG_FUNC_LINK_TRY(C)],
 #undef $1
 
 /* Tell Clang to allow disagreement with declaration of builtin $1.  */
-#ifdef __clang__
+#if defined __clang__ && 4 <= __clang_major__
 # pragma clang diagnostic ignored "-Wincompatible-library-redeclaration"
 #endif
 
-/* Tell MSVC to forget about builtin $1.  */
-#ifdef _MSC_VER
-__pragma (warning (disable : 4163))
-__pragma (function ($1))
-#endif
-
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-- 
2.53.0

Reply via email to