From f358d8ddab84e94e63a2c21e7d47290bdfc3f2a8 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 14 Apr 2022 00:52:26 +0200
Subject: [PATCH] string, wchar: Fix error in C++ mode on glibc systems with
 clang.

* lib/string.in.h (free): Add exception specification like glibc does.
* lib/wchar.in.h (free): Likewise.
---
 ChangeLog       | 6 ++++++
 lib/string.in.h | 8 ++++++++
 lib/wchar.in.h  | 8 ++++++++
 3 files changed, 22 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index c44700e0c2..9aada6c913 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-04-13  Bruno Haible  <bruno@clisp.org>
+
+	string, wchar: Fix error in C++ mode on glibc systems with clang.
+	* lib/string.in.h (free): Add exception specification like glibc does.
+	* lib/wchar.in.h (free): Likewise.
+
 2022-04-13  Bruno Haible  <bruno@clisp.org>
 
 	string: Fix errors in C++ mode on glibc systems with clang.
diff --git a/lib/string.in.h b/lib/string.in.h
index b818ae9cdf..b6840fa912 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -125,14 +125,22 @@ _GL_EXTERN_C void rpl_free (void *);
 #  if defined _MSC_VER
 _GL_EXTERN_C void __cdecl free (void *);
 #  else
+#   if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void free (void *) throw ();
+#   else
 _GL_EXTERN_C void free (void *);
+#   endif
 #  endif
 # endif
 #else
 # if defined _MSC_VER
 _GL_EXTERN_C void __cdecl free (void *);
 # else
+#  if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void free (void *) throw ();
+#  else
 _GL_EXTERN_C void free (void *);
+#  endif
 # endif
 #endif
 
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index d7792e5fb7..0d5c0b7abe 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -188,14 +188,22 @@ _GL_EXTERN_C void rpl_free (void *);
 #  if defined _MSC_VER
 _GL_EXTERN_C void __cdecl free (void *);
 #  else
+#   if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void free (void *) throw ();
+#   else
 _GL_EXTERN_C void free (void *);
+#   endif
 #  endif
 # endif
 #else
 # if defined _MSC_VER
 _GL_EXTERN_C void __cdecl free (void *);
 # else
+#  if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
+_GL_EXTERN_C void free (void *) throw ();
+#  else
 _GL_EXTERN_C void free (void *);
+#  endif
 # endif
 #endif
 
-- 
2.39.5