]> Savannah Git Hosting - gnulib.git/commitdiff
Fix some g++ warnings "has a different exception specifier".
authorBruno Haible <bruno@clisp.org>
Mon, 4 Sep 2023 17:22:21 +0000 (19:22 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 4 Sep 2023 17:22:21 +0000 (19:22 +0200)
* m4/gnulib-common.m4 (gl_COMMON_BODY): Make _GL_ATTRIBUTE_NOTHROW
effective in C++ mode.
* lib/attribute.h (ATTRIBUTE_NOTHROW): Add a comment.
* lib/malloc.in.h (_GL_ATTRIBUTE_NOTHROW): Provide fallback definition.
(memalign): Invoke _GL_FUNCDECL_SYS with _GL_ATTRIBUTE_NOTHROW.
* lib/stdio.in.h (_GL_ATTRIBUTE_NOTHROW): Provide fallback definition.
(fdopen): Invoke _GL_FUNCDECL_SYS with _GL_ATTRIBUTE_NOTHROW.
* lib/stdlib.in.h (_GL_ATTRIBUTE_NOTHROW): Provide fallback definition.
(aligned_alloc, calloc, canonicalize_file_name, malloc, realloc): Invoke
_GL_FUNCDECL_SYS with _GL_ATTRIBUTE_NOTHROW.
* lib/string.in.h (_GL_ATTRIBUTE_NOTHROW): Provide fallback definition.
(strdup, strndup): Invoke _GL_FUNCDECL_SYS with _GL_ATTRIBUTE_NOTHROW.
* lib/sys_stat.in.h (_GL_ATTRIBUTE_NOTHROW): Provide fallback
definition.
(getumask): Invoke _GL_FUNCDECL_SYS with _GL_ATTRIBUTE_NOTHROW.
* lib/wchar.in.h (_GL_ATTRIBUTE_NOTHROW): Provide fallback definition.
(wcsdup): Invoke _GL_FUNCDECL_SYS with _GL_ATTRIBUTE_NOTHROW.

ChangeLog
lib/attribute.h
lib/malloc.in.h
lib/stdio.in.h
lib/stdlib.in.h
lib/string.in.h
lib/sys_stat.in.h
lib/wchar.in.h
m4/gnulib-common.m4

index faf7eb7a7036b669da1d1cfdc86889b63e07984d..3324ceae54a2175871d92a373ac0cfc70d2f802b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2023-09-04  Bruno Haible  <bruno@clisp.org>
+
+       Fix some g++ warnings "has a different exception specifier".
+       * m4/gnulib-common.m4 (gl_COMMON_BODY): Make _GL_ATTRIBUTE_NOTHROW
+       effective in C++ mode.
+       * lib/attribute.h (ATTRIBUTE_NOTHROW): Add a comment.
+       * lib/malloc.in.h (_GL_ATTRIBUTE_NOTHROW): Provide fallback definition.
+       (memalign): Invoke _GL_FUNCDECL_SYS with _GL_ATTRIBUTE_NOTHROW.
+       * lib/stdio.in.h (_GL_ATTRIBUTE_NOTHROW): Provide fallback definition.
+       (fdopen): Invoke _GL_FUNCDECL_SYS with _GL_ATTRIBUTE_NOTHROW.
+       * lib/stdlib.in.h (_GL_ATTRIBUTE_NOTHROW): Provide fallback definition.
+       (aligned_alloc, calloc, canonicalize_file_name, malloc, realloc): Invoke
+       _GL_FUNCDECL_SYS with _GL_ATTRIBUTE_NOTHROW.
+       * lib/string.in.h (_GL_ATTRIBUTE_NOTHROW): Provide fallback definition.
+       (strdup, strndup): Invoke _GL_FUNCDECL_SYS with _GL_ATTRIBUTE_NOTHROW.
+       * lib/sys_stat.in.h (_GL_ATTRIBUTE_NOTHROW): Provide fallback
+       definition.
+       (getumask): Invoke _GL_FUNCDECL_SYS with _GL_ATTRIBUTE_NOTHROW.
+       * lib/wchar.in.h (_GL_ATTRIBUTE_NOTHROW): Provide fallback definition.
+       (wcsdup): Invoke _GL_FUNCDECL_SYS with _GL_ATTRIBUTE_NOTHROW.
+
 2023-09-04  Bruno Haible  <bruno@clisp.org>
 
        unistr/u{8,16,32}-strchr tests: Fix some gcc -Wshadow warnings.
index 9464fde0f307bac50fc70282d3dc25b2e764c9ea..e4e36092b013f791bc05d7ca2afaccc832a05855 100644 (file)
 
 /* The function does not throw exceptions.  */
 /* Applies to: functions.  */
+/* After a function's parameter list, this attribute must come first, before
+   other attributes.  */
 #define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW
 
 /* Do not inline the function.  */
index fe0e87c9c96ab33e4edb76a784d5cd650d9048d3..bfc749545e19f4c1e138bb7e2ae8134405b44b80 100644 (file)
@@ -46,7 +46,8 @@
 #ifndef _@GUARD_PREFIX@_MALLOC_H
 #define _@GUARD_PREFIX@_MALLOC_H
 
-/* This file uses _GL_ATTRIBUTE_DEALLOC, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*.  */
+/* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_NOTHROW,
+   GNULIB_POSIXCHECK, HAVE_RAW_DECL_*.  */
 #if !_GL_CONFIG_H_INCLUDED
  #error "Please include config.h first."
 #endif
 /* Get size_t.  */
 #include <stddef.h>
 
+
+/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
+ */
+#ifndef _GL_ATTRIBUTE_NOTHROW
+# if defined __cplusplus
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
+#   if __cplusplus >= 201103L
+#    define _GL_ATTRIBUTE_NOTHROW noexcept (true)
+#   else
+#    define _GL_ATTRIBUTE_NOTHROW throw ()
+#   endif
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# else
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
+#   define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# endif
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
@@ -127,6 +151,7 @@ _GL_CXXALIAS_RPL (memalign, void *, (size_t alignment, size_t size));
 /* For -Wmismatched-dealloc: Associate memalign with free or rpl_free.  */
 _GL_FUNCDECL_SYS (memalign, void *,
                   (size_t alignment, size_t size)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ATTRIBUTE_DEALLOC_FREE);
 #   endif
 _GL_CXXALIAS_SYS (memalign, void *, (size_t alignment, size_t size));
@@ -140,6 +165,7 @@ _GL_CXXALIASWARN (memalign);
 /* For -Wmismatched-dealloc: Associate memalign with free or rpl_free.  */
 _GL_FUNCDECL_SYS (memalign, void *,
                   (size_t alignment, size_t size)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ATTRIBUTE_DEALLOC_FREE);
 # endif
 # if defined GNULIB_POSIXCHECK
index 6be12c0525d9bd9ed8bb7e0cdbf8888b92dfda10..684c7a28263762aaeb1013e6397d3a719273ed0d 100644 (file)
@@ -58,7 +58,8 @@
 #define _@GUARD_PREFIX@_STDIO_H
 
 /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT,
-   _GL_ATTRIBUTE_MALLOC, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*.  */
+   _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK,
+   HAVE_RAW_DECL_*.  */
 #if !_GL_CONFIG_H_INCLUDED
  #error "Please include config.h first."
 #endif
 # endif
 #endif
 
+/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
+ */
+#ifndef _GL_ATTRIBUTE_NOTHROW
+# if defined __cplusplus
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
+#   if __cplusplus >= 201103L
+#    define _GL_ATTRIBUTE_NOTHROW noexcept (true)
+#   else
+#    define _GL_ATTRIBUTE_NOTHROW throw ()
+#   endif
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# else
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
+#   define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# endif
+#endif
+
 /* An __attribute__ __format__ specifier for a function that takes a format
    string and arguments, where the format string directives are the ones
    standardized by ISO C99 and POSIX.
@@ -346,6 +369,7 @@ _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
 /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose.  */
 _GL_FUNCDECL_SYS (fdopen, FILE *,
                   (int fd, const char *mode)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
                   _GL_ATTRIBUTE_MALLOC);
 #  endif
@@ -357,6 +381,7 @@ _GL_CXXALIASWARN (fdopen);
 /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose.  */
 _GL_FUNCDECL_SYS (fdopen, FILE *,
                   (int fd, const char *mode)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
                   _GL_ATTRIBUTE_MALLOC);
 # endif
index 1479a2b28719218cc104beda6b299260296ee554..10bb811d9e0b65c1536f3e764a34536f151dc244 100644 (file)
@@ -38,7 +38,8 @@
 #define _@GUARD_PREFIX@_STDLIB_H
 
 /* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
-   _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*.  */
+   _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
+   HAVE_RAW_DECL_*.  */
 #if !_GL_CONFIG_H_INCLUDED
  #error "Please include config.h first."
 #endif
@@ -132,6 +133,28 @@ struct random_data
 # endif
 #endif
 
+/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
+ */
+#ifndef _GL_ATTRIBUTE_NOTHROW
+# if defined __cplusplus
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
+#   if __cplusplus >= 201103L
+#    define _GL_ATTRIBUTE_NOTHROW noexcept (true)
+#   else
+#    define _GL_ATTRIBUTE_NOTHROW throw ()
+#   endif
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# else
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
+#   define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# endif
+#endif
+
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The attribute __pure__ was added in gcc 2.96.  */
 #ifndef _GL_ATTRIBUTE_PURE
@@ -236,6 +259,7 @@ _GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size));
 /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free.  */
 _GL_FUNCDECL_SYS (aligned_alloc, void *,
                   (size_t alignment, size_t size)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 #   endif
 _GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
@@ -249,6 +273,7 @@ _GL_CXXALIASWARN (aligned_alloc);
 /* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free.  */
 _GL_FUNCDECL_SYS (aligned_alloc, void *,
                   (size_t alignment, size_t size)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 # endif
 # if defined GNULIB_POSIXCHECK
@@ -294,6 +319,7 @@ _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
 /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free.  */
 _GL_FUNCDECL_SYS (calloc, void *,
                   (size_t nmemb, size_t size)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 #  endif
 _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
@@ -306,6 +332,7 @@ _GL_CXXALIASWARN (calloc);
 /* For -Wmismatched-dealloc: Associate calloc with free or rpl_free.  */
 _GL_FUNCDECL_SYS (calloc, void *,
                   (size_t nmemb, size_t size)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 # endif
 # if defined GNULIB_POSIXCHECK
@@ -330,6 +357,7 @@ _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
 #  if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11
 _GL_FUNCDECL_SYS (canonicalize_file_name, char *,
                   (const char *name)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ARG_NONNULL ((1))
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 #  endif
@@ -346,6 +374,7 @@ _GL_CXXALIASWARN (canonicalize_file_name);
    rpl_free.  */
 _GL_FUNCDECL_SYS (canonicalize_file_name, char *,
                   (const char *name)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ARG_NONNULL ((1))
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 # endif
@@ -571,6 +600,7 @@ _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
 /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free.  */
 _GL_FUNCDECL_SYS (malloc, void *,
                   (size_t size)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 #  endif
 _GL_CXXALIAS_SYS (malloc, void *, (size_t size));
@@ -583,6 +613,7 @@ _GL_CXXALIASWARN (malloc);
 /* For -Wmismatched-dealloc: Associate malloc with free or rpl_free.  */
 _GL_FUNCDECL_SYS (malloc, void *,
                   (size_t size)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 # endif
 # if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
@@ -1292,8 +1323,10 @@ _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
 # else
 #  if __GNUC__ >= 11
 /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free.  */
-_GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size)
-                                   _GL_ATTRIBUTE_DEALLOC_FREE);
+_GL_FUNCDECL_SYS (realloc, void *,
+                  (void *ptr, size_t size)
+                  _GL_ATTRIBUTE_NOTHROW
+                  _GL_ATTRIBUTE_DEALLOC_FREE);
 #  endif
 _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
 # endif
@@ -1303,8 +1336,10 @@ _GL_CXXALIASWARN (realloc);
 #else
 # if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc
 /* For -Wmismatched-dealloc: Associate realloc with free or rpl_free.  */
-_GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size)
-                                   _GL_ATTRIBUTE_DEALLOC_FREE);
+_GL_FUNCDECL_SYS (realloc, void *,
+                  (void *ptr, size_t size)
+                  _GL_ATTRIBUTE_NOTHROW
+                  _GL_ATTRIBUTE_DEALLOC_FREE);
 # endif
 # if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
 #  undef realloc
index 912d0f7a306f2d0f684e844415c0b083e35b767a..f7e6f3b18e39686ebf86d27af049578d9f5b221e 100644 (file)
@@ -45,7 +45,8 @@
 #define _@GUARD_PREFIX@_STRING_H
 
 /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
-   _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*.  */
+   _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
+   HAVE_RAW_DECL_*.  */
 #if !_GL_CONFIG_H_INCLUDED
  #error "Please include config.h first."
 #endif
 # endif
 #endif
 
+/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
+ */
+#ifndef _GL_ATTRIBUTE_NOTHROW
+# if defined __cplusplus
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
+#   if __cplusplus >= 201103L
+#    define _GL_ATTRIBUTE_NOTHROW noexcept (true)
+#   else
+#    define _GL_ATTRIBUTE_NOTHROW throw ()
+#   endif
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# else
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
+#   define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# endif
+#endif
+
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The attribute __pure__ was added in gcc 2.96.  */
 #ifndef _GL_ATTRIBUTE_PURE
@@ -578,6 +601,7 @@ _GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
 #  if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup
 _GL_FUNCDECL_SYS (strdup, char *,
                   (char const *__s)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ARG_NONNULL ((1))
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 #  endif
@@ -589,6 +613,7 @@ _GL_CXXALIASWARN (strdup);
 /* For -Wmismatched-dealloc: Associate strdup with free or rpl_free.  */
 _GL_FUNCDECL_SYS (strdup, char *,
                   (char const *__s)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ARG_NONNULL ((1))
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 # endif
@@ -661,6 +686,7 @@ _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
 #  if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup)
 _GL_FUNCDECL_SYS (strndup, char *,
                   (char const *__s, size_t __n)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ARG_NONNULL ((1))
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 #  endif
@@ -672,6 +698,7 @@ _GL_CXXALIASWARN (strndup);
 /* For -Wmismatched-dealloc: Associate strndup with free or rpl_free.  */
 _GL_FUNCDECL_SYS (strndup, char *,
                   (char const *__s, size_t __n)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ARG_NONNULL ((1))
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 # endif
index ad4da17fa46d21e1da50ea4e3c58f4d6adbfac05..3da98eb382b544f21ffb270431fd063fffd38f2e 100644 (file)
 #ifndef _@GUARD_PREFIX@_SYS_STAT_H
 #define _@GUARD_PREFIX@_SYS_STAT_H
 
-/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*.  */
+/* This file uses _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*.  */
 #if !_GL_CONFIG_H_INCLUDED
  #error "Please include config.h first."
 #endif
 
+
+/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
+ */
+#ifndef _GL_ATTRIBUTE_NOTHROW
+# if defined __cplusplus
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
+#   if __cplusplus >= 201103L
+#    define _GL_ATTRIBUTE_NOTHROW noexcept (true)
+#   else
+#    define _GL_ATTRIBUTE_NOTHROW throw ()
+#   endif
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# else
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
+#   define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# endif
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
+
 /* Before doing "#define mknod rpl_mknod" below, we need to include all
    headers that may declare mknod().  OS/2 kLIBC declares mknod() in
    <unistd.h>, not in <sys/stat.h>.  */
@@ -575,7 +599,7 @@ _GL_WARN_ON_USE (futimens, "futimens is not portable - "
 
 #if @GNULIB_GETUMASK@
 # if !@HAVE_GETUMASK@
-_GL_FUNCDECL_SYS (getumask, mode_t, (void));
+_GL_FUNCDECL_SYS (getumask, mode_t, (void) _GL_ATTRIBUTE_NOTHROW);
 # endif
 _GL_CXXALIAS_SYS (getumask, mode_t, (void));
 # if @HAVE_GETUMASK@
index 510f2025372986cae16017a6d5eaa3d640403fb7..f40c800bc9de25c0c56b2a180d8f290b745054dd 100644 (file)
@@ -85,7 +85,8 @@
 #define _@GUARD_PREFIX@_WCHAR_H
 
 /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
-   _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*.  */
+   _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
+   HAVE_RAW_DECL_*.  */
 #if !_GL_CONFIG_H_INCLUDED
  #error "Please include config.h first."
 #endif
 # endif
 #endif
 
+/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
+ */
+#ifndef _GL_ATTRIBUTE_NOTHROW
+# if defined __cplusplus
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
+#   if __cplusplus >= 201103L
+#    define _GL_ATTRIBUTE_NOTHROW noexcept (true)
+#   else
+#    define _GL_ATTRIBUTE_NOTHROW throw ()
+#   endif
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# else
+#  if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
+#   define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
+# endif
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
@@ -1305,6 +1328,7 @@ _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
 #  if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11
 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
                   (const wchar_t *s)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 #  endif
 _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
@@ -1315,6 +1339,7 @@ _GL_CXXALIASWARN (wcsdup);
 /* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free.  */
 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
                   (const wchar_t *s)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 # endif
 # if defined GNULIB_POSIXCHECK
@@ -1336,6 +1361,7 @@ _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
 #  else
 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
                   (const wchar_t *s)
+                  _GL_ATTRIBUTE_NOTHROW
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 #   if @HAVE_DECL_WCSDUP@
 _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
index 2426eb639852f5e7d07e1c04e609cb174f2e3498..c3723161356c0d42a9e5b03676dad8a58058a8d3 100644 (file)
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 87
+# gnulib-common.m4 serial 88
 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -466,11 +466,25 @@ AC_DEFUN([gl_COMMON_BODY], [
 /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
  */
 /* Applies to: functions.  */
+/* After a function's parameter list, this attribute must come first, before
+   other attributes.  */
 #ifndef _GL_ATTRIBUTE_NOTHROW
-# if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus
-#  define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
+# if defined __cplusplus
+#  if _GL_GNUC_PREREQ (2, 8) || __clang_major >= 4
+#   if __cplusplus >= 201103L
+#    define _GL_ATTRIBUTE_NOTHROW noexcept (true)
+#   else
+#    define _GL_ATTRIBUTE_NOTHROW throw ()
+#   endif
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
 # else
-#  define _GL_ATTRIBUTE_NOTHROW
+#  if _GL_HAS_ATTRIBUTE (nothrow)
+#   define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
+#  else
+#   define _GL_ATTRIBUTE_NOTHROW
+#  endif
 # endif
 #endif