On 2026-05-02 17:00, Collin Funk wrote:
What do you think is the best way to fix this? Perhaps AC_C_RESTRICT in
m4/gnulib-common.m4 can remove the definition on GCC or Clang? The
comment in that macro makes it seem that the use of __restrict__ is for
soley for other compilers.

It's needed for all C++ compilers, and for archaic C compilers that don't support plain "restrict". I installed the attached into both Autoconf and Gnulib, and I hope it works around this somewhat messy problem. Thanks for reporting it.
From e16e872076736447fe5e1bbb6bbb73d982efbe63 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Mon, 4 May 2026 14:07:12 -0700
Subject: [PATCH] =?UTF-8?q?Pacify=20GCC=2016=20-Wkeyword-macro=20for=20?=
 =?UTF-8?q?=E2=80=98restrict=E2=80=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Collin Funk in:
https://lists.gnu.org/r/bug-gnulib/2026-05/msg00011.html
* m4/gnulib-common.m4 (AC_C_RESTRICT): Sync from Autoconf Savannah
git commit b692310133c217edd7cbeeb1ddf592a18dab945f, and override
for Autoconf 2.73 and earlier.  This protects the "#undef
restrict", which may transmute into "#define restrict
__restrict__", if ! (defined __STDC_VERSION__ && 199901L <=
__STDC_VERSION__).
---
 ChangeLog           | 12 ++++++++++++
 m4/gnulib-common.m4 | 12 +++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 93ea77b811..1280ae5e18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2026-05-04  Paul Eggert  <[email protected]>
+
+	Pacify GCC 16 -Wkeyword-macro for ‘restrict’
+	Problem reported by Collin Funk in:
+	https://lists.gnu.org/r/bug-gnulib/2026-05/msg00011.html
+	* m4/gnulib-common.m4 (AC_C_RESTRICT): Sync from Autoconf Savannah
+	git commit b692310133c217edd7cbeeb1ddf592a18dab945f, and override
+	for Autoconf 2.73 and earlier.  This protects the "#undef
+	restrict", which may transmute into "#define restrict
+	__restrict__", if ! (defined __STDC_VERSION__ && 199901L <=
+	__STDC_VERSION__).
+
 2026-05-03  Bruno Haible  <[email protected]>
 
 	acl-permissions: Use the counted_by attribute.
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index e11be3cc84..5a804d5b4d 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,5 +1,5 @@
 # gnulib-common.m4
-# serial 117
+# serial 118
 dnl Copyright (C) 2007-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,
@@ -1251,9 +1251,9 @@ AC_DEFUN([gl_PROG_AR_RANLIB]
 ])
 
 # AC_C_RESTRICT
-# This definition is copied from post-2.70 Autoconf and overrides the
-# AC_C_RESTRICT macro from autoconf 2.60..2.70.
-m4_version_prereq([2.70.1], [], [
+# This definition is copied from post-2.73 Autoconf and overrides the
+# AC_C_RESTRICT macro from autoconf 2.60..2.73.
+m4_version_prereq([2.73.1], [], [
 AC_DEFUN([AC_C_RESTRICT],
 [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
   [ac_cv_c_restrict=no
@@ -1280,8 +1280,10 @@ AC_DEFUN([AC_C_RESTRICT]
  AH_VERBATIM([restrict],
 [/* Define to the equivalent of the C99 'restrict' keyword, or to
    nothing if this is not supported.  Do not define if restrict is
-   supported only directly.  */
+   supported directly.  */
+#if ! (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__)
 #undef restrict
+#endif
 /* Work around a bug in older versions of Sun C++, which did not
    #define __restrict__ or support _Restrict or __restrict__
    even though the corresponding Sun C compiler ended up with
-- 
2.54.0

Reply via email to