bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH
@ 2021-07-31 19:01 Paul Eggert
  2021-07-31 19:01 ` [PATCH 2/6] manywarnings: document GCC 11 warnings Paul Eggert
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Paul Eggert @ 2021-07-31 19:01 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

* doc/posix-headers/limits.texi (limits.h): Document them.
* lib/limits.in.h: Also define CHAR_WIDTH etc. if C2x.
(BOOL_MAX, BOOL_WIDTH): New macros, from C2x.
* m4/limits-h.m4 (gl_LIMITS_H): Also check BOOL_WIDTH.
---
 ChangeLog                     |  8 ++++++++
 doc/posix-headers/limits.texi |  4 ++++
 lib/limits.in.h               | 16 +++++++++++++---
 m4/limits-h.m4                |  3 ++-
 4 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d8a9bb1b8..dbf648571 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-07-30  Paul Eggert  <eggert@cs.ucla.edu>
+
+	limits-h: add BOOL_MAX, BOOL_WIDTH
+	* doc/posix-headers/limits.texi (limits.h): Document them.
+	* lib/limits.in.h: Also define CHAR_WIDTH etc. if C2x.
+	(BOOL_MAX, BOOL_WIDTH): New macros, from C2x.
+	* m4/limits-h.m4 (gl_LIMITS_H): Also check BOOL_WIDTH.
+
 2021-07-28  Simon Josefsson  <simon@josefsson.org>
 
 	maintainer-makefile: Respect cfg.mk setting announcement_Cc_,
diff --git a/doc/posix-headers/limits.texi b/doc/posix-headers/limits.texi
index edfc71619..22dc4239f 100644
--- a/doc/posix-headers/limits.texi
+++ b/doc/posix-headers/limits.texi
@@ -17,6 +17,10 @@ glibc 2.11 without @code{-D_GNU_SOURCE}, Cygwin, mingw, MSVC 14.
 @item
 Macros like @code{CHAR_WIDTH} are not defined on some platforms:
 glibc 2.24, NetBSD 9.0, many others.
+@item
+The macros @code{BOOL_MAX} and @code{BOOL_WIDTH} are not defined on
+some platforms:
+glibc 2.32, many others.
 @end itemize
 
 Portability problems fixed by Gnulib module @code{gethostname}:
diff --git a/lib/limits.in.h b/lib/limits.in.h
index 65ea12dbc..2ecafebb0 100644
--- a/lib/limits.in.h
+++ b/lib/limits.in.h
@@ -99,10 +99,11 @@
 # endif
 #endif
 
-/* Macros specified by ISO/IEC TS 18661-1:2014.  */
+/* Macros specified by C2x and by ISO/IEC TS 18661-1:2014.  */
 
 #if (! defined ULLONG_WIDTH                                             \
-     && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
+     && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__ \
+         || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
 # define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
 # define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX)
 # define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX)
@@ -114,7 +115,16 @@
 # define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX)
 # define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX)
 # define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX)
-#endif /* !ULLONG_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
+#endif
+
+/* Macros specified by C2x.  */
+
+#if (! defined BOOL_WIDTH \
+     && (defined _GNU_SOURCE \
+         || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
+# define BOOL_MAX 1
+# define BOOL_WIDTH 1
+#endif
 
 #endif /* _@GUARD_PREFIX@_LIMITS_H */
 #endif /* _@GUARD_PREFIX@_LIMITS_H */
diff --git a/m4/limits-h.m4 b/m4/limits-h.m4
index 70dbb7dcf..00c9fe9e5 100644
--- a/m4/limits-h.m4
+++ b/m4/limits-h.m4
@@ -11,7 +11,7 @@ AC_DEFUN_ONCE([gl_LIMITS_H],
 [
   gl_CHECK_NEXT_HEADERS([limits.h])
 
-  AC_CACHE_CHECK([whether limits.h has LLONG_MAX, WORD_BIT, ULLONG_WIDTH etc.],
+  AC_CACHE_CHECK([whether limits.h has WORD_BIT, BOOL_WIDTH etc.],
     [gl_cv_header_limits_width],
     [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM(
@@ -22,6 +22,7 @@ AC_DEFUN_ONCE([gl_LIMITS_H],
             long long llm = LLONG_MAX;
             int wb = WORD_BIT;
             int ullw = ULLONG_WIDTH;
+            int bw = BOOL_WIDTH;
           ]])],
        [gl_cv_header_limits_width=yes],
        [gl_cv_header_limits_width=no])])
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/6] manywarnings: document GCC 11 warnings
  2021-07-31 19:01 [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Paul Eggert
@ 2021-07-31 19:01 ` Paul Eggert
  2021-07-31 19:01 ` [PATCH 3/6] gnulib-common: update for C2x 2020-12-11 draft Paul Eggert
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Paul Eggert @ 2021-07-31 19:01 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

* build-aux/gcc-warning.spec: Add warnings introduced in GCC 11.
None of them require Gnulib code changes, so this is just
a documentation change.
---
 ChangeLog                  |  5 +++++
 build-aux/gcc-warning.spec | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index dbf648571..5a1534844 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2021-07-30  Paul Eggert  <eggert@cs.ucla.edu>
 
+	manywarnings: document GCC 11 warnings
+	* build-aux/gcc-warning.spec: Add warnings introduced in GCC 11.
+	None of them require Gnulib code changes, so this is just
+	a documentation change.
+
 	limits-h: add BOOL_MAX, BOOL_WIDTH
 	* doc/posix-headers/limits.texi (limits.h): Document them.
 	* lib/limits.in.h: Also define CHAR_WIDTH etc. if C2x.
diff --git a/build-aux/gcc-warning.spec b/build-aux/gcc-warning.spec
index 3f7e886c5..c0d49f2a6 100644
--- a/build-aux/gcc-warning.spec
+++ b/build-aux/gcc-warning.spec
@@ -24,18 +24,25 @@
 -Wanalyzer-file-leak			enabled by -fanalyzer
 -Wanalyzer-free-of-non-heap		enabled by -fanalyzer
 -Wanalyzer-malloc-leak			enabled by -fanalyzer
+-Wanalyzer-mismatching-deallocation	enabled by -fanalyzer
 -Wanalyzer-null-argument		enabled by -fanalyzer
 -Wanalyzer-null-dereference		enabled by -fanalyzer
 -Wanalyzer-possible-null-argument	enabled by -fanalyzer
 -Wanalyzer-possible-null-dereference	enabled by -fanalyzer
+-Wanalyzer-shift-count-negative		enabled by -fanalyzer
+-Wanalyzer-shift-count-overflow		enabled by -fanalyzer
 -Wanalyzer-stale-setjmp-buffer		implied by -fanalyzer
 -Wanalyzer-tainted-array-index		FIXME maybe? too much noise
 -Wanalyzer-too-complex			enabled by -fanalyzer
 -Wanalyzer-unsafe-call-within-signal-handler	enabled by -fanalyzer
 -Wanalyzer-use-after-free		enabled by -fanalyzer
 -Wanalyzer-use-of-pointer-in-stale-stack-frame	enabled by -fanalyzer
+-Wanalyzer-write-to-const		enabled by -fanalyzer
+-Wanalyzer-write-to-string-literal	enabled by -fanalyzer
 -Warray-bounds				covered by -Warray-bounds=
 -Warray-bounds=<0,2>			handled specially by gl_MANYWARN_ALL_GCC
+-Warray-parameter			enabled by -Wall
+-Warray-parameter=<0,2>			enabled by -Wall
 -Warray-temporaries			fortran
 -Wassign-intercept			objc/objc++
 -Wattribute-alias			covered by -Wattribute-alias=2
@@ -81,6 +88,7 @@
 -Wconversion-null			c++ and objc++
 -Wcoverage-mismatch			default
 -Wcpp					default
+-Wctad-maybe-unsupported		c++ and objc++
 -Wctor-dtor-privacy			c++
 -Wdangling-else				enabled by -Wparentheses
 -Wdeclaration-after-statement		needed only for pre-C99, so obsolete
@@ -90,6 +98,8 @@
 -Wdeprecated-copy			c++ and objc++
 -Wdeprecated-copy-dtor			c++ and objc++
 -Wdeprecated-declarations		default
+-Wdeprecated-enum-enum-conversion	c++ and objc++
+-Wdeprecated-enum-float-conversion	c++ and objc++
 -Wdesignated-init			default
 -Wdiscarded-array-qualifiers		default
 -Wdiscarded-qualifiers			default
@@ -102,6 +112,7 @@
 -Wenum-conversion			enabled by -Wextra
 -Wendif-labels				default
 -Werror-implicit-function-declaration	deprecated
+-Wexceptions				c++ and objc++
 -Wexpansion-to-defined			enabled by -Wextra
 -Wextra-semi				c++
 -Wfloat-conversion			FIXME maybe? borderline.  some will want this
@@ -144,6 +155,7 @@
 -Winteger-division			fortran
 -Wintrinsic-shadow			fortran
 -Wintrinsics-std			fortran
+-Winvalid-imported-macros		c++ and objc++
 -Winvalid-memory-model			default
 -Winvalid-offsetof			c++ and objc++
 -Wjump-misses-init			only useful for code meant to be compiled by a C++ compiler
@@ -159,6 +171,8 @@
 -Wmemset-elt-size			enabled by -Wall
 -Wmemset-transposed-args		enabled by -Wall
 -Wmisleading-indentation		enabled by -Wall
+-Wmismatched-dealloc			default
+-Wmismatched-new-delete			default, c++ and objc++
 -Wmismatched-tags			c++ and objc++
 -Wmissing-attributes			enabled by -Wall
 -Wmissing-braces			enabled by -Wall
@@ -186,6 +200,8 @@
 -Wnonnull-compare			enabled by -Wall
 -Wnormalized				default
 -Wnormalized=[none|id|nfc|nfkc]		defaults to nfc
+-WNSObject-attribute			objc and objc++
+-Wobjc-root-class			objc and objc++
 -Wodr					default
 -Wold-style-cast			c++ and objc++
 -Wold-style-declaration			enabled by -Wextra
@@ -211,6 +227,7 @@
 -Wproperty-assign-default		objc++
 -Wprotocol				objc++
 -Wpsabi					default
+-Wrange-loop-construct			c++ and objc++
 -Wreal-q-constant			fortran
 -Wrealloc-lhs				fortran
 -Wrealloc-lhs-all			fortran
@@ -241,6 +258,7 @@
 -Wsign-promo				c++ and objc++
 -Wsized-deallocation			c++ and objc++
 -Wsizeof-array-argument			default
+-Wsizeof-array-div			enabled by -Wall
 -Wsizeof-pointer-div			enabled by -Wall
 -Wsizeof-pointer-memaccess		enabled by -Wall
 -Wstack-usage=<byte-size>		FIXME: choose something sane?
@@ -252,6 +270,7 @@
 -Wstring-compare			enabled by -Wextra
 -Wstringop-overflow			covered by -Wstringop-overflow=2
 -Wstringop-overflow=<0,4>		defaults to 2
+-Wstringop-overread			default
 -Wstringop-truncation			default
 -Wsubobject-linkage			c++ and objc++
 -Wsuggest-override			c++ and objc++
@@ -271,6 +290,7 @@
 -Wtraditional				obsolescent
 -Wtraditional-conversion		obsolescent
 -Wtrigraphs				enabled by -Wall
+-Wtsan					default
 -Wtype-limits				enabled by -Wextra
 -Wundeclared-selector			objc and objc++
 -Wundef					FIXME maybe? too many false positives
@@ -294,9 +314,11 @@
 -Wuse-without-only			fortran
 -Wuseless-cast				c++ and objc++
 -Wvarargs				default
+-Wvexing-parse				c++ and objc++
 -Wvirtual-inheritance			c++
 -Wvirtual-move-assign			c++
 -Wvla-larger-than=<number>		handled specially by gl_MANYWARN_ALL_GCC
+-Wvla-parameter				enabled by -Wall
 -Wvolatile				c++ and objc++
 -Wvolatile-register-var			enabled by -Wall
 -Wzero-as-null-pointer-constant		c++ and objc++
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/6] gnulib-common: update for C2x 2020-12-11 draft
  2021-07-31 19:01 [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Paul Eggert
  2021-07-31 19:01 ` [PATCH 2/6] manywarnings: document GCC 11 warnings Paul Eggert
@ 2021-07-31 19:01 ` Paul Eggert
  2021-07-31 19:01 ` [PATCH 4/6] gnulib-common: update for gcc -Wmismatched-dealloc Paul Eggert
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Paul Eggert @ 2021-07-31 19:01 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

Use blessed-by-draft-standard way to test for [[__deprecated__]]
etc.; this is supported by GCC 11 and the fallback code should
work fine with GCC 10 and earlier, clang, etc.
* NEWS, doc/attribute.texi:
Mention that DEPRECATED etc. must now come first.
* lib/fflush.c, lib/unistr.in.h:
Do not include unused-parameter.h.  All uses of _GL_UNUSED_PARAMETER
(after parameters) replaced by _GL_ATTRIBUTE_MAYBE_UNUSED (before
parameters).  Although perhaps we need a shorter name for
_GL_ATTRIBUTE_MAYBE_UNUSED, that should probably be in
gnulib-common.m4, due to the ubiquity of this issue.
And perhaps the snippet/unused-parameter module should be marked
obsolete since it's no longer compatible with its old use.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macro
_GL_HAS_C_ATTRIBUTE, and use it instead of __STDC_VERSION__ in
deciding whether to use C2x attributes like [[__deprecated__]].
(_GL_ATTRIBUTE_MAYBE_UNUSED): Fall back on _GL_ATTRIBUTE_UNUSED.
(_GL_ATTRIBUTE_UNUSED): New macro, for labels where C2x
[[maybe_unused]] do not work.
(_GL_UNUSED, _GL_UNUSED_LABEL): Use it.
* modules/fflush, modules/unistr/base (Depends-on):
Remove snippet/unused-parameter.
* modules/fflush (selinux/selinux.h, selinux/context.h)
(selinux/label.h): Do not use $(UNUSED_PARAMETER).
Remove useless chmod a-x.
---
 ChangeLog                               |  8 ++++
 NEWS                                    |  9 ++++
 doc/attribute.texi                      |  8 ++++
 lib/anytostr.c                          |  2 +-
 lib/bitset.c                            |  2 +-
 lib/bitset/array.c                      | 10 ++---
 lib/bitset/list.c                       |  4 +-
 lib/bitset/stats.c                      |  2 +-
 lib/bitset/table.c                      |  2 +-
 lib/bitset/vector.c                     |  8 ++--
 lib/fflush.c                            |  6 +--
 lib/fts_.h                              | 17 +++++--
 lib/gl_anylinked_list2.h                |  6 +--
 lib/gl_anytree_list2.h                  | 14 +++---
 lib/gl_anytree_omap.h                   |  2 +-
 lib/gl_anytree_oset.h                   |  2 +-
 lib/gl_array_list.c                     |  2 +-
 lib/gl_array_omap.c                     |  2 +-
 lib/gl_array_oset.c                     |  2 +-
 lib/gl_carray_list.c                    |  2 +-
 lib/gl_list.h                           | 60 ++++++++++++-------------
 lib/gl_map.h                            | 12 ++---
 lib/gl_omap.h                           | 12 ++---
 lib/gl_oset.h                           |  7 +--
 lib/gl_set.h                            |  7 +--
 lib/hamt.h                              | 19 ++++----
 lib/hash.h                              | 20 ++++-----
 lib/inttostr.h                          | 10 ++---
 lib/safe-alloc.h                        |  2 +-
 lib/se-context.in.h                     | 42 ++++++++++-------
 lib/se-label.in.h                       | 18 ++++----
 lib/se-selinux.in.h                     | 56 +++++++++++------------
 lib/unistr.in.h                         |  8 ++--
 lib/unused-parameter.h                  | 13 +++---
 m4/gnulib-common.m4                     | 29 ++++++++----
 modules/fflush                          |  1 -
 modules/selinux-h                       | 17 +++----
 modules/unistr/base                     |  1 -
 tests/test-asyncsafe-linked_list-weak.c |  6 +--
 tests/test-ignore-value.c               | 10 ++---
 40 files changed, 248 insertions(+), 212 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5a1534844..7e388c4dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2021-07-30  Paul Eggert  <eggert@cs.ucla.edu>
 
+	gnulib-common: update for C2x 2020-12-11 draft
+	Use blessed-by-draft-standard way to test for [[__deprecated__]]
+	etc.; this is supported by GCC 11 and the fallback code should
+	work fine with GCC 10 and earlier.
+	* m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macro
+	_GL_HAS_C_ATTRIBUTE, and use it instead of __STDC_VERSION__ in
+	deciding whether to use C2x attributes like [[__deprecated__]].
+
 	manywarnings: document GCC 11 warnings
 	* build-aux/gcc-warning.spec: Add warnings introduced in GCC 11.
 	None of them require Gnulib code changes, so this is just
diff --git a/NEWS b/NEWS
index 345afb189..e0f0d836c 100644
--- a/NEWS
+++ b/NEWS
@@ -66,6 +66,15 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2021-07-29  (all)           Due to draft C2x, the following attributes should
+                            now appear at the start of a function declaration:
+                              _GL_ATTRIBUTE_DEPRECATED
+                              _GL_ATTRIBUTE_MAYBE_UNUSED
+                              _GL_ATTRIBUTE_NODISCARD
+            attribute       Likewise for DEPRECATED, MAYBE_UNUSED, NODISCARD.
+            snippet/unused-parameter
+                            Likewise for _GL_UNUSED_PARAMETER.
+
 2021-07-01  largefile       AC_SYS_LARGEFILE now also arranges for time_t
                             to be 64-bit on 32-bit GNU/Linux platforms
                             that support it (glibc 2.34 or later).
diff --git a/doc/attribute.texi b/doc/attribute.texi
index acc282ba9..983dfc350 100644
--- a/doc/attribute.texi
+++ b/doc/attribute.texi
@@ -23,11 +23,16 @@ Here is an example of its use:
 @example
 #include <attribute.h>
 
+NODISCARD
 extern char *crypt (char const *, char const *)
   ATTRIBUTE_NOTHROW ATTRIBUTE_LEAF ATTRIBUTE_NONNULL ((1, 2));
 @end example
 
 @noindent
+@code{NODISCARD} expands to @code{[[nodiscard]]} if the compiler
+supports this C2X syntax, otherwise to
+@code{__attribute__ ((__warn_unused_result__))} if the compiler
+is a recent-enough GCC or GCC-like compiler, otherwise to nothing.
 @code{ATTRIBUTE_NOTHROW} expands to @code{__attribute__
 ((__nothrow__))} if the compiler is a recent-enough GCC or GCC-like
 compiler, and to nothing otherwise.  Similarly for
@@ -41,3 +46,6 @@ names are not likely to clash with other macro names.
 These macros are @code{DEPRECATED}, @code{FALLTHROUGH},
 @code{MAYBE_UNUSED}, and @code{NODISCARD}, which can
 be defined to @code{[[deprecated]]} etc.@: on C2X platforms.
+Also, these exceptional macros should be placed at the start of
+function declarations, whereas the @code{ATTRIBUTE_*} macros can be
+placed at the end.
diff --git a/lib/anytostr.c b/lib/anytostr.c
index 6daecb46a..8294353f9 100644
--- a/lib/anytostr.c
+++ b/lib/anytostr.c
@@ -32,7 +32,7 @@
    INT_BUFSIZE_BOUND (INTTYPE) bytes long.  Return the address of the
    printable string, which need not start at BUF.  */
 
-char * _GL_ATTRIBUTE_NODISCARD
+_GL_ATTRIBUTE_NODISCARD char *
 anytostr (inttype i, char *buf)
 {
   char *p = buf + INT_STRLEN_BOUND (inttype);
diff --git a/lib/bitset.c b/lib/bitset.c
index 42092a3bd..7725828d7 100644
--- a/lib/bitset.c
+++ b/lib/bitset.c
@@ -94,7 +94,7 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
    specified by ATTR.  For variable size bitsets, N_BITS is only a
    hint and may be zero.  */
 enum bitset_type
-bitset_type_choose (bitset_bindex n_bits MAYBE_UNUSED, unsigned attr)
+bitset_type_choose (MAYBE_UNUSED bitset_bindex n_bits, unsigned attr)
 {
   /* Check attributes.  */
   if (attr & BITSET_FIXED && attr & BITSET_VARIABLE)
diff --git a/lib/bitset/array.c b/lib/bitset/array.c
index 6179b79bf..a984edefd 100644
--- a/lib/bitset/array.c
+++ b/lib/bitset/array.c
@@ -84,7 +84,7 @@ abitset_small_list (bitset src, bitset_bindex *list,
 
 /* Set bit BITNO in bitset DST.  */
 static void
-abitset_set (bitset dst MAYBE_UNUSED, bitset_bindex bitno MAYBE_UNUSED)
+abitset_set (MAYBE_UNUSED bitset dst, MAYBE_UNUSED bitset_bindex bitno)
 {
   /* This should never occur for abitsets since we should always hit
      the cache.  It is likely someone is trying to access outside the
@@ -95,8 +95,8 @@ abitset_set (bitset dst MAYBE_UNUSED, bitset_bindex bitno MAYBE_UNUSED)
 
 /* Reset bit BITNO in bitset DST.  */
 static void
-abitset_reset (bitset dst MAYBE_UNUSED,
-               bitset_bindex bitno MAYBE_UNUSED)
+abitset_reset (MAYBE_UNUSED bitset dst,
+               MAYBE_UNUSED bitset_bindex bitno)
 {
   /* This should never occur for abitsets since we should always hit
      the cache.  It is likely someone is trying to access outside the
@@ -106,8 +106,8 @@ abitset_reset (bitset dst MAYBE_UNUSED,
 
 /* Test bit BITNO in bitset SRC.  */
 static bool
-abitset_test (bitset src MAYBE_UNUSED,
-              bitset_bindex bitno MAYBE_UNUSED)
+abitset_test (MAYBE_UNUSED bitset src,
+              MAYBE_UNUSED bitset_bindex bitno)
 {
   /* This should never occur for abitsets since we should always
      hit the cache.  */
diff --git a/lib/bitset/list.c b/lib/bitset/list.c
index eb6e260c8..6e8724ddd 100644
--- a/lib/bitset/list.c
+++ b/lib/bitset/list.c
@@ -1229,7 +1229,7 @@ struct bitset_vtable lbitset_vtable = {
 
 /* Return size of initial structure.  */
 size_t
-lbitset_bytes (bitset_bindex n_bits MAYBE_UNUSED)
+lbitset_bytes (MAYBE_UNUSED bitset_bindex n_bits)
 {
   return sizeof (struct lbitset_struct);
 }
@@ -1237,7 +1237,7 @@ lbitset_bytes (bitset_bindex n_bits MAYBE_UNUSED)
 
 /* Initialize a bitset.  */
 bitset
-lbitset_init (bitset bset, bitset_bindex n_bits MAYBE_UNUSED)
+lbitset_init (bitset bset, MAYBE_UNUSED bitset_bindex n_bits)
 {
   BITSET_NBITS_ (bset) = n_bits;
   bset->b.vtable = &lbitset_vtable;
diff --git a/lib/bitset/stats.c b/lib/bitset/stats.c
index 7bceb6b38..f998b2b55 100644
--- a/lib/bitset/stats.c
+++ b/lib/bitset/stats.c
@@ -208,7 +208,7 @@ bitset_stats_print_1 (FILE *file, const char *name,
 
 /* Print all bitset statistics to FILE.  */
 static void
-bitset_stats_print (FILE *file, bool verbose MAYBE_UNUSED)
+bitset_stats_print (FILE *file, MAYBE_UNUSED bool verbose)
 {
   if (!bitset_stats_info)
     return;
diff --git a/lib/bitset/table.c b/lib/bitset/table.c
index 3b8db2a7f..b74c8c1a7 100644
--- a/lib/bitset/table.c
+++ b/lib/bitset/table.c
@@ -1132,7 +1132,7 @@ struct bitset_vtable tbitset_vtable = {
 
 /* Return size of initial structure.  */
 size_t
-tbitset_bytes (bitset_bindex n_bits MAYBE_UNUSED)
+tbitset_bytes (MAYBE_UNUSED bitset_bindex n_bits)
 {
   return sizeof (struct tbitset_struct);
 }
diff --git a/lib/bitset/vector.c b/lib/bitset/vector.c
index 6203e11e0..f0dc5f5b5 100644
--- a/lib/bitset/vector.c
+++ b/lib/bitset/vector.c
@@ -126,7 +126,7 @@ vbitset_set (bitset dst, bitset_bindex bitno)
 
 /* Reset bit BITNO in bitset DST.  */
 static void
-vbitset_reset (bitset dst MAYBE_UNUSED, bitset_bindex bitno MAYBE_UNUSED)
+vbitset_reset (MAYBE_UNUSED bitset dst, MAYBE_UNUSED bitset_bindex bitno)
 {
   /* We must be accessing outside the cache so the bit is
      zero anyway.  */
@@ -135,8 +135,8 @@ vbitset_reset (bitset dst MAYBE_UNUSED, bitset_bindex bitno MAYBE_UNUSED)
 
 /* Test bit BITNO in bitset SRC.  */
 static bool
-vbitset_test (bitset src MAYBE_UNUSED,
-              bitset_bindex bitno MAYBE_UNUSED)
+vbitset_test (MAYBE_UNUSED bitset src,
+              MAYBE_UNUSED bitset_bindex bitno)
 {
   /* We must be accessing outside the cache so the bit is
      zero anyway.  */
@@ -964,7 +964,7 @@ struct bitset_vtable vbitset_vtable = {
 
 
 size_t
-vbitset_bytes (bitset_bindex n_bits MAYBE_UNUSED)
+vbitset_bytes (MAYBE_UNUSED bitset_bindex n_bits)
 {
   return sizeof (struct vbitset_struct);
 }
diff --git a/lib/fflush.c b/lib/fflush.c
index 7e27c67c1..8fe9d262d 100644
--- a/lib/fflush.c
+++ b/lib/fflush.c
@@ -28,8 +28,6 @@
 
 #include "stdio-impl.h"
 
-#include "unused-parameter.h"
-
 #undef fflush
 
 
@@ -96,8 +94,8 @@ restore_seek_optimization (FILE *fp, int saved_flags)
 # else
 
 static void
-update_fpos_cache (FILE *fp _GL_UNUSED_PARAMETER,
-                   off_t pos _GL_UNUSED_PARAMETER)
+update_fpos_cache (_GL_ATTRIBUTE_MAYBE_UNUSED FILE *fp,
+                   _GL_ATTRIBUTE_MAYBE_UNUSED off_t pos)
 {
 #  if defined __sferror || defined __DragonFly__ || defined __ANDROID__
   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
diff --git a/lib/fts_.h b/lib/fts_.h
index f1265302b..9f4419c0a 100644
--- a/lib/fts_.h
+++ b/lib/fts_.h
@@ -250,12 +250,21 @@ typedef struct _ftsent {
 } FTSENT;
 
 __BEGIN_DECLS
-FTSENT  *fts_children (FTS *, int) __THROW _GL_ATTRIBUTE_NODISCARD;
-int      fts_close (FTS *) __THROW _GL_ATTRIBUTE_NODISCARD;
+
+ _GL_ATTRIBUTE_NODISCARD
+FTSENT  *fts_children (FTS *, int) __THROW;
+
+_GL_ATTRIBUTE_NODISCARD
+int      fts_close (FTS *) __THROW;
+
+_GL_ATTRIBUTE_NODISCARD
 FTS     *fts_open (char * const *, int,
                    int (*)(const FTSENT **, const FTSENT **))
-  __THROW _GL_ATTRIBUTE_NODISCARD;
-FTSENT  *fts_read (FTS *) __THROW _GL_ATTRIBUTE_NODISCARD;
+  __THROW;
+
+_GL_ATTRIBUTE_NODISCARD
+FTSENT  *fts_read (FTS *) __THROW;
+
 int      fts_set (FTS *, FTSENT *, int) __THROW;
 __END_DECLS
 
diff --git a/lib/gl_anylinked_list2.h b/lib/gl_anylinked_list2.h
index 176403a7f..8ed54cab7 100644
--- a/lib/gl_anylinked_list2.h
+++ b/lib/gl_anylinked_list2.h
@@ -170,14 +170,14 @@ gl_linked_size (gl_list_t list)
 }
 
 static const void * _GL_ATTRIBUTE_PURE
-gl_linked_node_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
+gl_linked_node_value (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list,
                       gl_list_node_t node)
 {
   return node->value;
 }
 
 static int
-gl_linked_node_nx_set_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
+gl_linked_node_nx_set_value (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list,
                              gl_list_node_t node,
                              const void *elt)
 {
@@ -1041,7 +1041,7 @@ gl_linked_iterator_next (gl_list_iterator_t *iterator,
 }
 
 static void
-gl_linked_iterator_free (gl_list_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
+gl_linked_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_iterator_t *iterator)
 {
 }
 
diff --git a/lib/gl_anytree_list2.h b/lib/gl_anytree_list2.h
index 559ded61d..536fc30c6 100644
--- a/lib/gl_anytree_list2.h
+++ b/lib/gl_anytree_list2.h
@@ -60,14 +60,14 @@ gl_tree_size (gl_list_t list)
 }
 
 static const void * _GL_ATTRIBUTE_PURE
-gl_tree_node_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
+gl_tree_node_value (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list,
                     gl_list_node_t node)
 {
   return node->value;
 }
 
 static int
-gl_tree_node_nx_set_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
+gl_tree_node_nx_set_value (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list,
                            gl_list_node_t node, const void *elt)
 {
 #if WITH_HASHTABLE
@@ -103,7 +103,7 @@ gl_tree_node_nx_set_value (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
 }
 
 static gl_list_node_t _GL_ATTRIBUTE_PURE
-gl_tree_next_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
+gl_tree_next_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list,
                    gl_list_node_t node)
 {
   if (node->right != NULL)
@@ -122,7 +122,7 @@ gl_tree_next_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
 }
 
 static gl_list_node_t _GL_ATTRIBUTE_PURE
-gl_tree_previous_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
+gl_tree_previous_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list,
                        gl_list_node_t node)
 {
   if (node->left != NULL)
@@ -141,7 +141,7 @@ gl_tree_previous_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED,
 }
 
 static gl_list_node_t _GL_ATTRIBUTE_PURE
-gl_tree_first_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED)
+gl_tree_first_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list)
 {
   gl_list_node_t node = list->root;
 
@@ -154,7 +154,7 @@ gl_tree_first_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED)
 }
 
 static gl_list_node_t _GL_ATTRIBUTE_PURE
-gl_tree_last_node (gl_list_t list _GL_ATTRIBUTE_MAYBE_UNUSED)
+gl_tree_last_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list)
 {
   gl_list_node_t node = list->root;
 
@@ -658,7 +658,7 @@ gl_tree_iterator_next (gl_list_iterator_t *iterator,
 }
 
 static void
-gl_tree_iterator_free (gl_list_iterator_t *iterator  _GL_ATTRIBUTE_MAYBE_UNUSED)
+gl_tree_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_iterator_t *iterator)
 {
 }
 
diff --git a/lib/gl_anytree_omap.h b/lib/gl_anytree_omap.h
index 62c33a15a..0550ce749 100644
--- a/lib/gl_anytree_omap.h
+++ b/lib/gl_anytree_omap.h
@@ -300,6 +300,6 @@ gl_tree_iterator_next (gl_omap_iterator_t *iterator,
 }
 
 static void
-gl_tree_iterator_free (gl_omap_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
+gl_tree_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_omap_iterator_t *iterator)
 {
 }
diff --git a/lib/gl_anytree_oset.h b/lib/gl_anytree_oset.h
index 9f5161ac6..512320521 100644
--- a/lib/gl_anytree_oset.h
+++ b/lib/gl_anytree_oset.h
@@ -438,6 +438,6 @@ gl_tree_iterator_next (gl_oset_iterator_t *iterator, const void **eltp)
 }
 
 static void
-gl_tree_iterator_free (gl_oset_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
+gl_tree_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_oset_iterator_t *iterator)
 {
 }
diff --git a/lib/gl_array_list.c b/lib/gl_array_list.c
index 4d6500cd2..8485d60fd 100644
--- a/lib/gl_array_list.c
+++ b/lib/gl_array_list.c
@@ -527,7 +527,7 @@ gl_array_iterator_next (gl_list_iterator_t *iterator,
 }
 
 static void
-gl_array_iterator_free (gl_list_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
+gl_array_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_iterator_t *iterator)
 {
 }
 
diff --git a/lib/gl_array_omap.c b/lib/gl_array_omap.c
index b1e025777..d3d4e7b14 100644
--- a/lib/gl_array_omap.c
+++ b/lib/gl_array_omap.c
@@ -370,7 +370,7 @@ gl_array_iterator_next (gl_omap_iterator_t *iterator,
 }
 
 static void
-gl_array_iterator_free (gl_omap_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
+gl_array_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_omap_iterator_t *iterator)
 {
 }
 
diff --git a/lib/gl_array_oset.c b/lib/gl_array_oset.c
index 342c8d86e..146d54e81 100644
--- a/lib/gl_array_oset.c
+++ b/lib/gl_array_oset.c
@@ -488,7 +488,7 @@ gl_array_iterator_next (gl_oset_iterator_t *iterator, const void **eltp)
 }
 
 static void
-gl_array_iterator_free (gl_oset_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
+gl_array_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_oset_iterator_t *iterator)
 {
 }
 
diff --git a/lib/gl_carray_list.c b/lib/gl_carray_list.c
index 33f233860..f7fa0d118 100644
--- a/lib/gl_carray_list.c
+++ b/lib/gl_carray_list.c
@@ -699,7 +699,7 @@ gl_carray_iterator_next (gl_list_iterator_t *iterator,
 }
 
 static void
-gl_carray_iterator_free (gl_list_iterator_t *iterator _GL_ATTRIBUTE_MAYBE_UNUSED)
+gl_carray_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_iterator_t *iterator)
 {
 }
 
diff --git a/lib/gl_list.h b/lib/gl_list.h
index d600580ef..e2da4f1b8 100644
--- a/lib/gl_list.h
+++ b/lib/gl_list.h
@@ -197,9 +197,9 @@ extern const void * gl_list_node_value (gl_list_t list, gl_list_node_t node);
 extern void gl_list_node_set_value (gl_list_t list, gl_list_node_t node,
                                     const void *elt);
 /* Likewise.  Returns 0 upon success, -1 upon out-of-memory.  */
+_GL_ATTRIBUTE_NODISCARD
 extern int gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node,
-                                      const void *elt)
-  _GL_ATTRIBUTE_NODISCARD;
+                                      const void *elt);
 
 /* Returns the node immediately after the given node in the list, or NULL
    if the given node is the last (rightmost) one in the list.  */
@@ -245,9 +245,9 @@ extern const void * gl_list_get_last (gl_list_t list);
 extern gl_list_node_t gl_list_set_at (gl_list_t list, size_t position,
                                       const void *elt);
 /* Likewise.  Returns NULL upon out-of-memory.  */
+_GL_ATTRIBUTE_NODISCARD
 extern gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position,
-                                         const void *elt)
-  _GL_ATTRIBUTE_NODISCARD;
+                                         const void *elt);
 
 /* Replaces the element at the first position in the list.
    Returns its node.
@@ -255,8 +255,8 @@ extern gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position,
 /* declared in gl_xlist.h */
 extern gl_list_node_t gl_list_set_first (gl_list_t list, const void *elt);
 /* Likewise.  Returns NULL upon out-of-memory.  */
-extern gl_list_node_t gl_list_nx_set_first (gl_list_t list, const void *elt)
-  _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern gl_list_node_t gl_list_nx_set_first (gl_list_t list, const void *elt);
 
 /* Replaces the element at the last position in the list.
    Returns its node.
@@ -264,8 +264,8 @@ extern gl_list_node_t gl_list_nx_set_first (gl_list_t list, const void *elt)
 /* declared in gl_xlist.h */
 extern gl_list_node_t gl_list_set_last (gl_list_t list, const void *elt);
 /* Likewise.  Returns NULL upon out-of-memory.  */
-extern gl_list_node_t gl_list_nx_set_last (gl_list_t list, const void *elt)
-  _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern gl_list_node_t gl_list_nx_set_last (gl_list_t list, const void *elt);
 
 /* Searches whether an element is already in the list.
    Returns its node if found, or NULL if not present in the list.  */
@@ -307,16 +307,16 @@ extern size_t gl_list_indexof_from_to (gl_list_t list,
 /* declared in gl_xlist.h */
 extern gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt);
 /* Likewise.  Returns NULL upon out-of-memory.  */
-extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt)
-  _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt);
 
 /* Adds an element as the last element of the list.
    Returns its node.  */
 /* declared in gl_xlist.h */
 extern gl_list_node_t gl_list_add_last (gl_list_t list, const void *elt);
 /* Likewise.  Returns NULL upon out-of-memory.  */
-extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt)
-  _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt);
 
 /* Adds an element before a given element node of the list.
    Returns its node.  */
@@ -324,10 +324,10 @@ extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt)
 extern gl_list_node_t gl_list_add_before (gl_list_t list, gl_list_node_t node,
                                           const void *elt);
 /* Likewise.  Returns NULL upon out-of-memory.  */
+_GL_ATTRIBUTE_NODISCARD
 extern gl_list_node_t gl_list_nx_add_before (gl_list_t list,
                                              gl_list_node_t node,
-                                             const void *elt)
-  _GL_ATTRIBUTE_NODISCARD;
+                                             const void *elt);
 
 /* Adds an element after a given element node of the list.
    Returns its node.  */
@@ -335,9 +335,9 @@ extern gl_list_node_t gl_list_nx_add_before (gl_list_t list,
 extern gl_list_node_t gl_list_add_after (gl_list_t list, gl_list_node_t node,
                                          const void *elt);
 /* Likewise.  Returns NULL upon out-of-memory.  */
+_GL_ATTRIBUTE_NODISCARD
 extern gl_list_node_t gl_list_nx_add_after (gl_list_t list, gl_list_node_t node,
-                                            const void *elt)
-  _GL_ATTRIBUTE_NODISCARD;
+                                            const void *elt);
 
 /* Adds an element at a given position in the list.
    POSITION must be >= 0 and <= gl_list_size (list).  */
@@ -345,9 +345,9 @@ extern gl_list_node_t gl_list_nx_add_after (gl_list_t list, gl_list_node_t node,
 extern gl_list_node_t gl_list_add_at (gl_list_t list, size_t position,
                                       const void *elt);
 /* Likewise.  Returns NULL upon out-of-memory.  */
+_GL_ATTRIBUTE_NODISCARD
 extern gl_list_node_t gl_list_nx_add_at (gl_list_t list, size_t position,
-                                         const void *elt)
-  _GL_ATTRIBUTE_NODISCARD;
+                                         const void *elt);
 
 /* Removes an element from the list.
    Returns true.  */
@@ -488,10 +488,10 @@ extern gl_list_node_t gl_sortedlist_add (gl_list_t list,
                                          gl_listelement_compar_fn compar,
                                          const void *elt);
 /* Likewise.  Returns NULL upon out-of-memory.  */
+_GL_ATTRIBUTE_NODISCARD
 extern gl_list_node_t gl_sortedlist_nx_add (gl_list_t list,
                                             gl_listelement_compar_fn compar,
-                                            const void *elt)
-  _GL_ATTRIBUTE_NODISCARD;
+                                            const void *elt);
 
 /* Searches and removes an element from the list.
    The list is assumed to be sorted with COMPAR.
@@ -630,7 +630,7 @@ gl_list_node_value (gl_list_t list, gl_list_node_t node)
          ->node_value (list, node);
 }
 
-GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD int
+_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE int
 gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node,
                            const void *elt)
 {
@@ -685,20 +685,20 @@ gl_list_get_last (gl_list_t list)
   return gl_list_get_at (list, gl_list_size (list) - 1);
 }
 
-GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
+_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
 gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt)
 {
   return ((const struct gl_list_impl_base *) list)->vtable
          ->nx_set_at (list, position, elt);
 }
 
-GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
+_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
 gl_list_nx_set_first (gl_list_t list, const void *elt)
 {
   return gl_list_nx_set_at (list, 0, elt);
 }
 
-GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
+_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
 gl_list_nx_set_last (gl_list_t list, const void *elt)
 {
   return gl_list_nx_set_at (list, gl_list_size (list) - 1, elt);
@@ -752,35 +752,35 @@ gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index,
          ->indexof_from_to (list, start_index, end_index, elt);
 }
 
-GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
+_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
 gl_list_nx_add_first (gl_list_t list, const void *elt)
 {
   return ((const struct gl_list_impl_base *) list)->vtable
          ->nx_add_first (list, elt);
 }
 
-GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
+_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
 gl_list_nx_add_last (gl_list_t list, const void *elt)
 {
   return ((const struct gl_list_impl_base *) list)->vtable
          ->nx_add_last (list, elt);
 }
 
-GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
+_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
 gl_list_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
 {
   return ((const struct gl_list_impl_base *) list)->vtable
          ->nx_add_before (list, node, elt);
 }
 
-GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
+_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
 gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
 {
   return ((const struct gl_list_impl_base *) list)->vtable
          ->nx_add_after (list, node, elt);
 }
 
-GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
+_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
 gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt)
 {
   return ((const struct gl_list_impl_base *) list)->vtable
@@ -891,7 +891,7 @@ gl_sortedlist_indexof_from_to (gl_list_t list, gl_listelement_compar_fn compar,
                                        elt);
 }
 
-GL_LIST_INLINE _GL_ATTRIBUTE_NODISCARD gl_list_node_t
+_GL_ATTRIBUTE_NODISCARD GL_LIST_INLINE gl_list_node_t
 gl_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
 {
   return ((const struct gl_list_impl_base *) list)->vtable
diff --git a/lib/gl_map.h b/lib/gl_map.h
index 051ec5944..118d4e321 100644
--- a/lib/gl_map.h
+++ b/lib/gl_map.h
@@ -145,8 +145,8 @@ extern bool gl_map_search (gl_map_t map, const void *key, const void **valuep);
 /* declared in gl_xmap.h */
 extern bool gl_map_put (gl_map_t map, const void *key, const void *value);
 /* Likewise.  Returns -1 upon out-of-memory.  */
-extern int gl_map_nx_put (gl_map_t map, const void *key, const void *value)
-  _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern int gl_map_nx_put (gl_map_t map, const void *key, const void *value);
 
 /* Adds a pair to a map and retrieves the previous value.
    Returns true if a pair with the given key was not already in the map and so
@@ -157,9 +157,9 @@ extern int gl_map_nx_put (gl_map_t map, const void *key, const void *value)
 extern bool gl_map_getput (gl_map_t map, const void *key, const void *value,
                            const void **oldvaluep);
 /* Likewise.  Returns -1 upon out-of-memory.  */
+_GL_ATTRIBUTE_NODISCARD
 extern int gl_map_nx_getput (gl_map_t map, const void *key, const void *value,
-                             const void **oldvaluep)
-  _GL_ATTRIBUTE_NODISCARD;
+                             const void **oldvaluep);
 
 /* Removes a pair from a map.
    Returns true if the key was found and its pair removed.
@@ -280,7 +280,7 @@ gl_map_search (gl_map_t map, const void *key, const void **valuep)
          ->search (map, key, valuep);
 }
 
-GL_MAP_INLINE _GL_ATTRIBUTE_NODISCARD int
+_GL_ATTRIBUTE_NODISCARD GL_MAP_INLINE int
 gl_map_nx_getput (gl_map_t map, const void *key, const void *value,
                    const void **oldvaluep)
 {
@@ -331,7 +331,7 @@ gl_map_get (gl_map_t map, const void *key)
   return value;
 }
 
-GL_MAP_INLINE _GL_ATTRIBUTE_NODISCARD int
+_GL_ATTRIBUTE_NODISCARD GL_MAP_INLINE int
 gl_map_nx_put (gl_map_t map, const void *key, const void *value)
 {
   const void *oldvalue;
diff --git a/lib/gl_omap.h b/lib/gl_omap.h
index ca6916c82..b2dacfb28 100644
--- a/lib/gl_omap.h
+++ b/lib/gl_omap.h
@@ -155,8 +155,8 @@ extern bool gl_omap_search_atleast (gl_omap_t map,
 /* declared in gl_xomap.h */
 extern bool gl_omap_put (gl_omap_t map, const void *key, const void *value);
 /* Likewise.  Returns -1 upon out-of-memory.  */
-extern int gl_omap_nx_put (gl_omap_t map, const void *key, const void *value)
-  _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern int gl_omap_nx_put (gl_omap_t map, const void *key, const void *value);
 
 /* Adds a pair to an ordered map and retrieves the previous value.
    Returns true if a pair with the given key was not already in the map and so
@@ -167,9 +167,9 @@ extern int gl_omap_nx_put (gl_omap_t map, const void *key, const void *value)
 extern bool gl_omap_getput (gl_omap_t map, const void *key, const void *value,
                             const void **oldvaluep);
 /* Likewise.  Returns -1 upon out-of-memory.  */
+_GL_ATTRIBUTE_NODISCARD
 extern int gl_omap_nx_getput (gl_omap_t map, const void *key, const void *value,
-                              const void **oldvaluep)
-  _GL_ATTRIBUTE_NODISCARD;
+                              const void **oldvaluep);
 
 /* Removes a pair from an ordered map.
    Returns true if the key was found and its pair removed.
@@ -298,7 +298,7 @@ gl_omap_search_atleast (gl_omap_t map,
          ->search_atleast (map, threshold_fn, threshold, keyp, valuep);
 }
 
-GL_OMAP_INLINE _GL_ATTRIBUTE_NODISCARD int
+_GL_ATTRIBUTE_NODISCARD GL_OMAP_INLINE int
 gl_omap_nx_getput (gl_omap_t map, const void *key, const void *value,
                    const void **oldvaluep)
 {
@@ -349,7 +349,7 @@ gl_omap_get (gl_omap_t map, const void *key)
   return value;
 }
 
-GL_OMAP_INLINE _GL_ATTRIBUTE_NODISCARD int
+_GL_ATTRIBUTE_NODISCARD GL_OMAP_INLINE int
 gl_omap_nx_put (gl_omap_t map, const void *key, const void *value)
 {
   const void *oldvalue;
diff --git a/lib/gl_oset.h b/lib/gl_oset.h
index b9ce896d1..ac90f0445 100644
--- a/lib/gl_oset.h
+++ b/lib/gl_oset.h
@@ -134,9 +134,10 @@ extern bool gl_oset_search_atleast (gl_oset_t set,
    Returns true if it was not already in the set and added, false otherwise.  */
 /* declared in gl_xoset.h */
 extern bool gl_oset_add (gl_oset_t set, const void *elt);
+
 /* Likewise.  Returns -1 upon out-of-memory.  */
-extern int gl_oset_nx_add (gl_oset_t set, const void *elt)
-  _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern int gl_oset_nx_add (gl_oset_t set, const void *elt);
 
 /* Removes an element from an ordered set.
    Returns true if it was found and removed.  */
@@ -272,7 +273,7 @@ gl_oset_search_atleast (gl_oset_t set,
          ->search_atleast (set, threshold_fn, threshold, eltp);
 }
 
-GL_OSET_INLINE _GL_ATTRIBUTE_NODISCARD int
+_GL_ATTRIBUTE_NODISCARD GL_OSET_INLINE int
 gl_oset_nx_add (gl_oset_t set, const void *elt)
 {
   return ((const struct gl_oset_impl_base *) set)->vtable->nx_add (set, elt);
diff --git a/lib/gl_set.h b/lib/gl_set.h
index 3a05b9304..4e68cc739 100644
--- a/lib/gl_set.h
+++ b/lib/gl_set.h
@@ -124,9 +124,10 @@ extern bool gl_set_search (gl_set_t set, const void *elt);
    Returns true if it was not already in the set and added, false otherwise.  */
 /* declared in gl_xset.h */
 extern bool gl_set_add (gl_set_t set, const void *elt);
+
 /* Likewise.  Returns -1 upon out-of-memory.  */
-extern int gl_set_nx_add (gl_set_t set, const void *elt)
-  _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern int gl_set_nx_add (gl_set_t set, const void *elt);
 
 /* Removes an element from a set.
    Returns true if it was found and removed.  */
@@ -230,7 +231,7 @@ gl_set_search (gl_set_t set, const void *elt)
   return ((const struct gl_set_impl_base *) set)->vtable->search (set, elt);
 }
 
-GL_SET_INLINE _GL_ATTRIBUTE_NODISCARD int
+_GL_ATTRIBUTE_NODISCARD GL_SET_INLINE int
 gl_set_nx_add (gl_set_t set, const void *elt)
 {
   return ((const struct gl_set_impl_base *) set)->vtable->nx_add (set, elt);
diff --git a/lib/hamt.h b/lib/hamt.h
index 25a0ad9f9..6bbc6a3f4 100644
--- a/lib/hamt.h
+++ b/lib/hamt.h
@@ -139,14 +139,15 @@ typedef void (Hamt_freer) (Hamt_entry *elt);
 /****************************/
 
 /* Create and return a new and empty hash array mapped trie.  */
+_GL_ATTRIBUTE_NODISCARD
 extern Hamt *hamt_create (Hamt_hasher *hasher, Hamt_comparator *comparator,
-                          Hamt_freer *freer)
-  _GL_ATTRIBUTE_NODISCARD;
+                          Hamt_freer *freer);
 
 /* Return a copy of HAMT, which is not the same in the sense above.
    This procedure can be used, for example, so that two threads can
    access the same data independently.  */
-extern Hamt *hamt_copy (Hamt *hamt) _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern Hamt *hamt_copy (Hamt *hamt);
 
 /* Free the resources solely allocated by HAMT and all elements solely
    contained in it.  */
@@ -167,20 +168,20 @@ extern Hamt_entry *hamt_lookup (const Hamt *hamt, const void *elt);
 /* If *ELT_PTR matches an element already in HAMT, set *ELT_PTR to the
    existing element and return the original hamt.  Otherwise, insert
    *ELT_PTR into a copy of the hamt and return the copy.  */
-extern Hamt *hamt_insert (Hamt *hamt, Hamt_entry **elt_ptr)
-  _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern Hamt *hamt_insert (Hamt *hamt, Hamt_entry **elt_ptr);
 
 /* If *ELT_PTR matches an element already in HAMT, set *ELT_PTR to the
 existing element, remove the element from a copy of the hamt and
 return the copy.  Otherwise, return the original hamt.  */
-extern Hamt *hamt_remove (Hamt *hamt, Hamt_entry **elt_ptr)
-  _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern Hamt *hamt_remove (Hamt *hamt, Hamt_entry **elt_ptr);
 
 /* Insert *ELT_PTR into a copy of HAMT and return the copy.  If an
    existing element was replaced, set *ELT_PTR to this element, and to
    NULL otherwise.  */
-extern Hamt *hamt_replace (Hamt *hamt, Hamt_entry **elt_ptr)
-  _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern Hamt *hamt_replace (Hamt *hamt, Hamt_entry **elt_ptr);
 
 /*************/
 /* Iteration */
diff --git a/lib/hash.h b/lib/hash.h
index a52736d3b..230d5cd38 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -172,21 +172,21 @@ typedef void (*Hash_data_freer) (void *entry);
    all of your 'data' data.  This is typically the case when your data is
    simply an auxiliary struct that you have malloc'd to aggregate several
    values.  */
+_GL_ATTRIBUTE_NODISCARD
 extern Hash_table *hash_initialize (size_t candidate,
                                     const Hash_tuning *tuning,
                                     Hash_hasher hasher,
                                     Hash_comparator comparator,
-                                    Hash_data_freer data_freer)
-       _GL_ATTRIBUTE_NODISCARD;
+                                    Hash_data_freer data_freer);
 
 /* Same as hash_initialize, but invokes xalloc_die on memory exhaustion.  */
 /* This function is defined by module 'xhash'.  */
+_GL_ATTRIBUTE_NODISCARD
 extern Hash_table *hash_xinitialize (size_t candidate,
                                      const Hash_tuning *tuning,
                                      Hash_hasher hasher,
                                      Hash_comparator comparator,
-                                     Hash_data_freer data_freer)
-       _GL_ATTRIBUTE_NODISCARD;
+                                     Hash_data_freer data_freer);
 
 /* Make all buckets empty, placing any chained entries on the free list.
    Apply the user-specified function data_freer (if any) to the datas of any
@@ -210,16 +210,16 @@ extern void hash_free (Hash_table *table);
    those already in the table, before any other growth of the hash table size
    occurs.  If TUNING->IS_N_BUCKETS is true, then CANDIDATE specifies the
    exact number of buckets desired.  Return true iff the rehash succeeded.  */
-extern bool hash_rehash (Hash_table *table, size_t candidate)
-       _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern bool hash_rehash (Hash_table *table, size_t candidate);
 
 /* If ENTRY matches an entry already in the hash table, return the pointer
    to the entry from the table.  Otherwise, insert ENTRY and return ENTRY.
    Return NULL if the storage required for insertion cannot be allocated.
    This implementation does not support duplicate entries or insertion of
    NULL.  */
-extern void *hash_insert (Hash_table *table, const void *entry)
-       _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD
+extern void *hash_insert (Hash_table *table, const void *entry);
 
 /* Same as hash_insert, but invokes xalloc_die on memory exhaustion.  */
 /* This function is defined by module 'xhash'.  */
@@ -251,8 +251,8 @@ extern void *hash_remove (Hash_table *table, const void *entry);
 
 /* Same as hash_remove.  This interface is deprecated.
    FIXME: Remove in 2022.  */
-extern void *hash_delete (Hash_table *table, const void *entry)
-       _GL_ATTRIBUTE_DEPRECATED;
+_GL_ATTRIBUTE_DEPRECATED
+extern void *hash_delete (Hash_table *table, const void *entry);
 
 # ifdef __cplusplus
 }
diff --git a/lib/inttostr.h b/lib/inttostr.h
index 9dcac70e9..db1f8fa67 100644
--- a/lib/inttostr.h
+++ b/lib/inttostr.h
@@ -22,8 +22,8 @@
 
 #include "intprops.h"
 
-char *imaxtostr (intmax_t, char *) _GL_ATTRIBUTE_NODISCARD;
-char *inttostr (int, char *) _GL_ATTRIBUTE_NODISCARD;
-char *offtostr (off_t, char *) _GL_ATTRIBUTE_NODISCARD;
-char *uinttostr (unsigned int, char *) _GL_ATTRIBUTE_NODISCARD;
-char *umaxtostr (uintmax_t, char *) _GL_ATTRIBUTE_NODISCARD;
+_GL_ATTRIBUTE_NODISCARD char *imaxtostr (intmax_t, char *);
+_GL_ATTRIBUTE_NODISCARD char *inttostr (int, char *);
+_GL_ATTRIBUTE_NODISCARD char *offtostr (off_t, char *);
+_GL_ATTRIBUTE_NODISCARD char *uinttostr (unsigned int, char *);
+_GL_ATTRIBUTE_NODISCARD char *umaxtostr (uintmax_t, char *);
diff --git a/lib/safe-alloc.h b/lib/safe-alloc.h
index 3ba9d2fc2..b54d9b472 100644
--- a/lib/safe-alloc.h
+++ b/lib/safe-alloc.h
@@ -38,7 +38,7 @@ safe_alloc_realloc_n (void *ptr, size_t count, size_t size)
     count = size = 1;
   return reallocarray (ptr, count, size);
 }
-SAFE_ALLOC_INLINE int _GL_ATTRIBUTE_NODISCARD
+_GL_ATTRIBUTE_NODISCARD SAFE_ALLOC_INLINE int
 safe_alloc_check (void *ptr)
 {
   /* Return 0 if the allocation was successful, -1 otherwise.  */
diff --git a/lib/se-context.in.h b/lib/se-context.in.h
index 999a7b413..d4ed6a4c1 100644
--- a/lib/se-context.in.h
+++ b/lib/se-context.in.h
@@ -29,34 +29,42 @@ _GL_INLINE_HEADER_BEGIN
 # define SE_CONTEXT_INLINE _GL_INLINE
 #endif
 
-/* The definition of _GL_UNUSED_PARAMETER is copied here.  */
-
 typedef int context_t;
-SE_CONTEXT_INLINE context_t context_new (char const *s _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE context_t
+context_new (_GL_ATTRIBUTE_MAYBE_UNUSED char const *s)
   { errno = ENOTSUP; return 0; }
-SE_CONTEXT_INLINE char *context_str (context_t con _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE char *
+context_str (_GL_ATTRIBUTE_MAYBE_UNUSED context_t con)
   { errno = ENOTSUP; return (void *) 0; }
-SE_CONTEXT_INLINE void context_free (context_t c _GL_UNUSED_PARAMETER) {}
+SE_CONTEXT_INLINE void context_free (_GL_ATTRIBUTE_MAYBE_UNUSED context_t c) {}
 
-SE_CONTEXT_INLINE int context_user_set (context_t sc _GL_UNUSED_PARAMETER,
-                                        char const *s _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE int
+context_user_set (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc,
+                  _GL_ATTRIBUTE_MAYBE_UNUSED char const *s)
   { errno = ENOTSUP; return -1; }
-SE_CONTEXT_INLINE int context_role_set (context_t sc _GL_UNUSED_PARAMETER,
-                                        char const *s _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE int
+context_role_set (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc,
+                  _GL_ATTRIBUTE_MAYBE_UNUSED char const *s)
   { errno = ENOTSUP; return -1; }
-SE_CONTEXT_INLINE int context_range_set (context_t sc _GL_UNUSED_PARAMETER,
-                                         char const *s _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE int
+context_range_set (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc,
+                   _GL_ATTRIBUTE_MAYBE_UNUSED char const *s)
   { errno = ENOTSUP; return -1; }
-SE_CONTEXT_INLINE int context_type_set (context_t sc _GL_UNUSED_PARAMETER,
-                                        char const *s _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE int
+context_type_set (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc,
+                  _GL_ATTRIBUTE_MAYBE_UNUSED char const *s)
   { errno = ENOTSUP; return -1; }
-SE_CONTEXT_INLINE char *context_type_get (context_t sc _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE char *
+context_type_get (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc)
   { errno = ENOTSUP; return (void *) 0; }
-SE_CONTEXT_INLINE char *context_range_get (context_t sc _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE char *
+context_range_get (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc)
   { errno = ENOTSUP; return (void *) 0; }
-SE_CONTEXT_INLINE char *context_role_get (context_t sc _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE char *
+context_role_get (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc)
   { errno = ENOTSUP; return (void *) 0; }
-SE_CONTEXT_INLINE char *context_user_get (context_t sc _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE char *
+context_user_get (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc)
   { errno = ENOTSUP; return (void *) 0; }
 
 _GL_INLINE_HEADER_END
diff --git a/lib/se-label.in.h b/lib/se-label.in.h
index 8d8929745..2bf1eb88c 100644
--- a/lib/se-label.in.h
+++ b/lib/se-label.in.h
@@ -31,27 +31,25 @@ _GL_INLINE_HEADER_BEGIN
 # define SE_LABEL_INLINE _GL_INLINE
 #endif
 
-/* The definition of _GL_UNUSED_PARAMETER is copied here.  */
-
 #define SELABEL_CTX_FILE 0
 
 struct selabel_handle;
 
 SE_LABEL_INLINE int
-selabel_lookup (struct selabel_handle *hnd _GL_UNUSED_PARAMETER,
-                char **context _GL_UNUSED_PARAMETER,
-                char const *key _GL_UNUSED_PARAMETER,
-                int type _GL_UNUSED_PARAMETER)
+selabel_lookup (_GL_ATTRIBUTE_MAYBE_UNUSED struct selabel_handle *hnd,
+                _GL_ATTRIBUTE_MAYBE_UNUSED char **context,
+                _GL_ATTRIBUTE_MAYBE_UNUSED char const *key,
+                _GL_ATTRIBUTE_MAYBE_UNUSED int type)
 { errno = ENOTSUP; return -1; }
 
 SE_LABEL_INLINE struct selabel_handle *
-selabel_open (int backend _GL_UNUSED_PARAMETER,
-              struct selinux_opt *options _GL_UNUSED_PARAMETER,
-              unsigned nopt _GL_UNUSED_PARAMETER)
+selabel_open (_GL_ATTRIBUTE_MAYBE_UNUSED int backend,
+              _GL_ATTRIBUTE_MAYBE_UNUSED struct selinux_opt *options,
+              _GL_ATTRIBUTE_MAYBE_UNUSED unsigned nopt)
 { errno = ENOTSUP; return 0; }
 
 SE_LABEL_INLINE void
-selabel_close (struct selabel_handle *hnd _GL_UNUSED_PARAMETER)
+selabel_close (_GL_ATTRIBUTE_MAYBE_UNUSED struct selabel_handle *hnd)
 { errno = ENOTSUP; }
 
 _GL_INLINE_HEADER_END
diff --git a/lib/se-selinux.in.h b/lib/se-selinux.in.h
index 60cc493e6..85dae1181 100644
--- a/lib/se-selinux.in.h
+++ b/lib/se-selinux.in.h
@@ -38,8 +38,6 @@ _GL_INLINE_HEADER_BEGIN
 #   define SE_SELINUX_INLINE _GL_INLINE
 #  endif
 
-/* The definition of _GL_UNUSED_PARAMETER is copied here.  */
-
 #  if !GNULIB_defined_security_types
 
 typedef unsigned short security_class_t;
@@ -47,67 +45,67 @@ struct selinux_opt;
 #   define is_selinux_enabled() 0
 
 SE_SELINUX_INLINE int
-getcon (char **con _GL_UNUSED_PARAMETER)
+getcon (_GL_ATTRIBUTE_MAYBE_UNUSED char **con)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE void
-freecon (char *con _GL_UNUSED_PARAMETER) {}
+freecon (_GL_ATTRIBUTE_MAYBE_UNUSED char *con) {}
 
 SE_SELINUX_INLINE int
-getfscreatecon (char **con _GL_UNUSED_PARAMETER)
+getfscreatecon (_GL_ATTRIBUTE_MAYBE_UNUSED char **con)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE int
-setfscreatecon (char const *con _GL_UNUSED_PARAMETER)
+setfscreatecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE int
-matchpathcon (char const *file _GL_UNUSED_PARAMETER,
-              mode_t m _GL_UNUSED_PARAMETER,
-              char **con _GL_UNUSED_PARAMETER)
+matchpathcon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
+              _GL_ATTRIBUTE_MAYBE_UNUSED mode_t m,
+              _GL_ATTRIBUTE_MAYBE_UNUSED char **con)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE int
-getfilecon (char const *file _GL_UNUSED_PARAMETER,
-            char **con _GL_UNUSED_PARAMETER)
+getfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
+            _GL_ATTRIBUTE_MAYBE_UNUSED char **con)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE int
-lgetfilecon (char const *file _GL_UNUSED_PARAMETER,
-             char **con _GL_UNUSED_PARAMETER)
+lgetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
+             _GL_ATTRIBUTE_MAYBE_UNUSED char **con)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE int
-fgetfilecon (int fd, char **con _GL_UNUSED_PARAMETER)
+fgetfilecon (int fd,_GL_ATTRIBUTE_MAYBE_UNUSED char **con)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE int
-setfilecon (char const *file _GL_UNUSED_PARAMETER,
-            char const *con _GL_UNUSED_PARAMETER)
+setfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
+            _GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE int
-lsetfilecon (char const *file _GL_UNUSED_PARAMETER,
-             char const *con _GL_UNUSED_PARAMETER)
+lsetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file,
+             _GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE int
-fsetfilecon (int fd _GL_UNUSED_PARAMETER,
-             char const *con _GL_UNUSED_PARAMETER)
+fsetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED int fd,
+             _GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
   { errno = ENOTSUP; return -1; }
 
 SE_SELINUX_INLINE int
-security_check_context (char const *con _GL_UNUSED_PARAMETER)
+security_check_context (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE int
-security_check_context_raw (char const *con _GL_UNUSED_PARAMETER)
+security_check_context_raw (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE int
-setexeccon (char const *con _GL_UNUSED_PARAMETER)
+setexeccon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE int
-security_compute_create (char const *scon _GL_UNUSED_PARAMETER,
-                         char const *tcon _GL_UNUSED_PARAMETER,
-                         security_class_t tclass _GL_UNUSED_PARAMETER,
-                         char **newcon _GL_UNUSED_PARAMETER)
+security_compute_create (_GL_ATTRIBUTE_MAYBE_UNUSED char const *scon,
+                         _GL_ATTRIBUTE_MAYBE_UNUSED char const *tcon,
+                         _GL_ATTRIBUTE_MAYBE_UNUSED security_class_t tclass,
+                         _GL_ATTRIBUTE_MAYBE_UNUSED char **newcon)
   { errno = ENOTSUP; return -1; }
 SE_SELINUX_INLINE security_class_t
 string_to_security_class (char const *name)
   { errno = ENOTSUP; return 0; }
 SE_SELINUX_INLINE int
-matchpathcon_init_prefix (char const *path _GL_UNUSED_PARAMETER,
-                          char const *prefix _GL_UNUSED_PARAMETER)
+matchpathcon_init_prefix (_GL_ATTRIBUTE_MAYBE_UNUSED char const *path,
+                          _GL_ATTRIBUTE_MAYBE_UNUSED char const *prefix)
   { errno = ENOTSUP; return -1; }
 
 #   define GNULIB_defined_security_types 1
diff --git a/lib/unistr.in.h b/lib/unistr.in.h
index 2441a72b8..ed657773c 100644
--- a/lib/unistr.in.h
+++ b/lib/unistr.in.h
@@ -19,9 +19,6 @@
 
 #include "unitypes.h"
 
-/* Get common macros for C.  */
-#include "unused-parameter.h"
-
 /* Get bool.  */
 #include <stdbool.h>
 
@@ -193,7 +190,7 @@ extern int
 # else
 static inline int
 u32_mbtouc_unsafe (ucs4_t *puc,
-                   const uint32_t *s, size_t n _GL_UNUSED_PARAMETER)
+                   const uint32_t *s, _GL_ATTRIBUTE_MAYBE_UNUSED size_t n)
 {
   uint32_t c = *s;
 
@@ -259,7 +256,8 @@ extern int
        u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n);
 # else
 static inline int
-u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n _GL_UNUSED_PARAMETER)
+u32_mbtouc (ucs4_t *puc, const uint32_t *s,
+            _GL_ATTRIBUTE_MAYBE_UNUSED size_t n)
 {
   uint32_t c = *s;
 
diff --git a/lib/unused-parameter.h b/lib/unused-parameter.h
index 34f05d9ef..047a0d895 100644
--- a/lib/unused-parameter.h
+++ b/lib/unused-parameter.h
@@ -14,18 +14,15 @@
    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
-/* _GL_UNUSED_PARAMETER is a marker that can be appended to function parameter
+/* _GL_UNUSED_PARAMETER is a marker that can be prepended to function parameter
    declarations for parameters that are not used.  This helps to reduce
    warnings, such as from GCC -Wunused-parameter.  The syntax is as follows:
-       type param _GL_UNUSED_PARAMETER
+       _GL_UNUSED_PARAMETER type param
    or more generally
-       param_decl _GL_UNUSED_PARAMETER
+       _GL_UNUSED_PARAMETER param_decl
    For example:
-       int param _GL_UNUSED_PARAMETER
-       int *(*param)(void) _GL_UNUSED_PARAMETER
-   Other possible, but obscure and discouraged syntaxes:
-       int _GL_UNUSED_PARAMETER *(*param)(void)
-       _GL_UNUSED_PARAMETER int *(*param)(void)
+       _GL_UNUSED_PARAMETER int param
+       _GL_UNUSED_PARAMETER int *(*param) (void)
  */
 #ifndef _GL_UNUSED_PARAMETER
 # define _GL_UNUSED_PARAMETER _GL_ATTRIBUTE_MAYBE_UNUSED
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index bfa1645db..347462d1d 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -103,6 +103,12 @@ AC_DEFUN([gl_COMMON_BODY], [
 # define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
 #endif
 
+#ifdef __has_c_attribute
+# define _GL_HAS_C_ATTRIBUTE(attr) __has_c_attribute (__##attr##__)
+#else
+# define _GL_HAS_C_ATTRIBUTE(attr) 0
+#endif
+
 ]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's _Alignas instead.
 [
 #if _GL_HAS_ATTRIBUTE (alloc_size)
@@ -142,7 +148,7 @@ AC_DEFUN([gl_COMMON_BODY], [
 # define _GL_ATTRIBUTE_CONST
 #endif
 
-#if 201710L < __STDC_VERSION__
+#if _GL_HAS_C_ATTRIBUTE (deprecated)
 # define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
 #elif _GL_HAS_ATTRIBUTE (deprecated)
 # define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
@@ -168,7 +174,7 @@ AC_DEFUN([gl_COMMON_BODY], [
 #endif
 
 /* FALLTHROUGH is special, because it always expands to something.  */
-#if 201710L < __STDC_VERSION__
+#if _GL_HAS_C_ATTRIBUTE (fallthrough)
 # define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
 #elif _GL_HAS_ATTRIBUTE (fallthrough)
 # define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
@@ -195,15 +201,12 @@ AC_DEFUN([gl_COMMON_BODY], [
 # define _GL_ATTRIBUTE_MAY_ALIAS
 #endif
 
-#if 201710L < __STDC_VERSION__
+#if _GL_HAS_C_ATTRIBUTE (maybe_unused)
 # define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
-#elif _GL_HAS_ATTRIBUTE (unused)
-# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__))
 #else
-# define _GL_ATTRIBUTE_MAYBE_UNUSED
+# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED
 #endif
 /* Earlier spellings of this macro.  */
-#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
 #define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED
 
 #if _GL_HAS_ATTRIBUTE (malloc)
@@ -212,7 +215,7 @@ AC_DEFUN([gl_COMMON_BODY], [
 # define _GL_ATTRIBUTE_MALLOC
 #endif
 
-#if 201710L < __STDC_VERSION__
+#if _GL_HAS_C_ATTRIBUTE (nodiscard)
 # define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
 #elif _GL_HAS_ATTRIBUTE (warn_unused_result)
 # define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
@@ -270,11 +273,19 @@ AC_DEFUN([gl_COMMON_BODY], [
 # define _GL_ATTRIBUTE_SENTINEL(pos)
 #endif
 
+#if _GL_HAS_ATTRIBUTE (unused)
+# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+#else
+# define _GL_ATTRIBUTE_UNUSED
+#endif
+/* Earlier spellings of this macro.  */
+#define _GL_UNUSED _GL_ATTRIBUTE_UNUSED
+
 ]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead.
 [
 /* To support C++ as well as C, use _GL_UNUSED_LABEL with trailing ';'.  */
 #if !defined __cplusplus || _GL_GNUC_PREREQ (4, 5)
-# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_MAYBE_UNUSED
+# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED
 #else
 # define _GL_UNUSED_LABEL
 #endif
diff --git a/modules/fflush b/modules/fflush
index 858a25aaf..bda975a2a 100644
--- a/modules/fflush
+++ b/modules/fflush
@@ -8,7 +8,6 @@ m4/fflush.m4
 
 Depends-on:
 stdio
-snippet/unused-parameter  [test $REPLACE_FFLUSH = 1]
 fpurge                    [test $REPLACE_FFLUSH = 1]
 ftello                    [test $REPLACE_FFLUSH = 1]
 freading                  [test $REPLACE_FFLUSH = 1]
diff --git a/modules/selinux-h b/modules/selinux-h
index 26face8a7..00328bf20 100644
--- a/modules/selinux-h
+++ b/modules/selinux-h
@@ -16,7 +16,6 @@ m4/selinux-selinux-h.m4
 Depends-on:
 errno
 extern-inline
-snippet/unused-parameter
 
 configure.ac:
 gl_HEADERS_SELINUX_SELINUX_H
@@ -31,7 +30,7 @@ lib_SOURCES += se-context.in.h se-label.in.h se-selinux.in.h \
   se-context.c se-label.c se-selinux.c
 
 BUILT_SOURCES += selinux/selinux.h
-selinux/selinux.h: se-selinux.in.h $(top_builddir)/config.status $(UNUSED_PARAMETER_H)
+selinux/selinux.h: se-selinux.in.h $(top_builddir)/config.status
 	$(AM_V_at)$(MKDIR_P) selinux
 	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
@@ -40,23 +39,19 @@ selinux/selinux.h: se-selinux.in.h $(top_builddir)/config.status $(UNUSED_PARAME
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
 	      -e 's|@''NEXT_SELINUX_SELINUX_H''@|$(NEXT_SELINUX_SELINUX_H)|g' \
-	      -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \
 	      < $(srcdir)/se-selinux.in.h; \
 	} > $@-t && \
-	chmod a-x $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += selinux/selinux.h selinux/selinux.h-t
 
 BUILT_SOURCES += $(SELINUX_CONTEXT_H)
 if GL_GENERATE_SELINUX_CONTEXT_H
-selinux/context.h: se-context.in.h $(top_builddir)/config.status $(UNUSED_PARAMETER_H)
+selinux/context.h: se-context.in.h $(top_builddir)/config.status
 	$(AM_V_at)$(MKDIR_P) selinux
 	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
-	  sed -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \
-	      < $(srcdir)/se-context.in.h; \
+	  cat $(srcdir)/se-context.in.h; \
 	} > $@-t && \
-	chmod a-x $@-t && \
 	mv $@-t $@
 else
 selinux/context.h: $(top_builddir)/config.status
@@ -66,14 +61,12 @@ MOSTLYCLEANFILES += selinux/context.h selinux/context.h-t
 
 BUILT_SOURCES += $(SELINUX_LABEL_H)
 if GL_GENERATE_SELINUX_LABEL_H
-selinux/label.h: se-label.in.h $(top_builddir)/config.status $(UNUSED_PARAMETER_H)
+selinux/label.h: se-label.in.h $(top_builddir)/config.status
 	$(AM_V_at)$(MKDIR_P) selinux
 	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
-	  sed -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \
-	      < $(srcdir)/se-label.in.h; \
+	  cat $(srcdir)/se-label.in.h; \
 	} > $@-t && \
-	chmod a-x $@-t && \
 	mv $@-t $@
 else
 selinux/label.h: $(top_builddir)/config.status
diff --git a/modules/unistr/base b/modules/unistr/base
index a85fdab4d..4f2fb3737 100644
--- a/modules/unistr/base
+++ b/modules/unistr/base
@@ -7,7 +7,6 @@ m4/libunistring-base.m4
 
 Depends-on:
 unitypes
-snippet/unused-parameter
 stdbool
 inline
 
diff --git a/tests/test-asyncsafe-linked_list-weak.c b/tests/test-asyncsafe-linked_list-weak.c
index f2b0d61c2..e0596017c 100644
--- a/tests/test-asyncsafe-linked_list-weak.c
+++ b/tests/test-asyncsafe-linked_list-weak.c
@@ -128,7 +128,7 @@ bag_from_list (gl_list_t list)
 }
 
 /* Returns true if and only if the given bag is empty.  */
-static bool _GL_ATTRIBUTE_MAYBE_UNUSED
+_GL_ATTRIBUTE_MAYBE_UNUSED static bool
 bag_is_empty (bag_t bag)
 {
   size_t i;
@@ -165,7 +165,7 @@ bag_equals (bag_t bag1, bag_t bag2)
 
 /* Returns a bag that contains the elements of BAG1 and the elements of
    BAG2.  */
-static bag_t _GL_ATTRIBUTE_MAYBE_UNUSED
+_GL_ATTRIBUTE_MAYBE_UNUSED static bag_t
 bag_or (bag_t bag1, bag_t bag2)
 {
   bag_t bag;
@@ -192,7 +192,7 @@ bag_xor (bag_t bag1, bag_t bag2)
 }
 
 /* Returns a bag that contains the elements of BAG1 that are not in BAG2.  */
-static bag_t _GL_ATTRIBUTE_MAYBE_UNUSED
+_GL_ATTRIBUTE_MAYBE_UNUSED static bag_t
 bag_and_not (bag_t bag1, bag_t bag2)
 {
   bag_t bag;
diff --git a/tests/test-ignore-value.c b/tests/test-ignore-value.c
index 3b8d0a691..6191d7dd3 100644
--- a/tests/test-ignore-value.c
+++ b/tests/test-ignore-value.c
@@ -26,11 +26,11 @@
 #include "attribute.h"
 
 struct s { int i; };
-static char doChar (void) NODISCARD;
-static int doInt (void) NODISCARD;
-static off_t doOff (void) NODISCARD;
-static void *doPtr (void) NODISCARD;
-static struct s doStruct (void) NODISCARD;
+NODISCARD static char doChar (void);
+NODISCARD static int doInt (void);
+NODISCARD static off_t doOff (void);
+NODISCARD static void *doPtr (void);
+NODISCARD static struct s doStruct (void);
 
 static char
 doChar (void)
-- 
2.31.1




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/6] gnulib-common: update for gcc -Wmismatched-dealloc
  2021-07-31 19:01 [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Paul Eggert
  2021-07-31 19:01 ` [PATCH 2/6] manywarnings: document GCC 11 warnings Paul Eggert
  2021-07-31 19:01 ` [PATCH 3/6] gnulib-common: update for C2x 2020-12-11 draft Paul Eggert
@ 2021-07-31 19:01 ` Paul Eggert
  2021-07-31 19:01 ` [PATCH 5/6] xalloc: add malloc-related function attributes Paul Eggert
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Paul Eggert @ 2021-07-31 19:01 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

* m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macros
_GL_ATTRIBUTE_DEALLOC and _GL_ATTRIBUTE_DEALLOC_FREE.  These can
be useful with gcc -Wmismatched-dealloc.
---
 ChangeLog           |  5 +++++
 m4/gnulib-common.m4 | 12 ++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 7e388c4dd..33a472f5e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2021-07-30  Paul Eggert  <eggert@cs.ucla.edu>
 
+	gnulib-common: update for gcc -Wmismatched-dealloc
+	* m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macros
+	_GL_ATTRIBUTE_DEALLOC and _GL_ATTRIBUTE_DEALLOC_FREE.  These can
+	be useful with gcc -Wmismatched-dealloc.
+
 	gnulib-common: update for C2x 2020-12-11 draft
 	Use blessed-by-draft-standard way to test for [[__deprecated__]]
 	etc.; this is supported by GCC 11 and the fallback code should
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 347462d1d..2872ecdf7 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -148,6 +148,18 @@ AC_DEFUN([gl_COMMON_BODY], [
 # define _GL_ATTRIBUTE_CONST
 #endif
 
+/* _GL_ATTRIBUTE_DEALLOC (F, I) is for functions returning pointers
+   that can be freed by passing them as the Ith argument to the
+   function F.  _GL_ATTRIBUTE_DEALLOC_FREE is for functions that
+   return pointers that can be freed via 'free'; it can be used
+   only after including stdlib.h.  */
+#if _GL_GNUC_PREREQ (11, 0)
+# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
+#else
+# define _GL_ATTRIBUTE_DEALLOC(f, i)
+#endif
+#define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
+
 #if _GL_HAS_C_ATTRIBUTE (deprecated)
 # define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
 #elif _GL_HAS_ATTRIBUTE (deprecated)
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/6] xalloc: add malloc-related function attributes
  2021-07-31 19:01 [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Paul Eggert
                   ` (2 preceding siblings ...)
  2021-07-31 19:01 ` [PATCH 4/6] gnulib-common: update for gcc -Wmismatched-dealloc Paul Eggert
@ 2021-07-31 19:01 ` Paul Eggert
  2021-07-31 19:01 ` [PATCH 6/6] doc: C2X -> C2x Paul Eggert
  2021-08-01 13:38 ` [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Bruno Haible
  5 siblings, 0 replies; 7+ messages in thread
From: Paul Eggert @ 2021-07-31 19:01 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

* lib/quotearg.h, lib/xalloc.h: Include stdlib.h, for
the benefit of _GL_ATTRIBUTE_DALLOC_FREE.
* lib/quotearg.h (clone_quoting_options):
* lib/xalloc.h (xmalloc, ximalloc, xzalloc, xizalloc, xcalloc)
(xicalloc, xrealloc, xirealloc, xireallocarray, x2realloc)
(x2nrealloc, xmemdup, ximemdup, xstrdup, xnmalloc, xcharalloc):
Add _GL_ATTRIBUTE_DALLOC_FREE and _GL_ATTRIBUTE_RETURNS_NONNULL
attributes as appropriate.
---
 ChangeLog      | 10 ++++++++
 lib/quotearg.h |  6 +++--
 lib/xalloc.h   | 65 ++++++++++++++++++++++++++++++++++----------------
 3 files changed, 59 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 33a472f5e..00224486f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2021-07-30  Paul Eggert  <eggert@cs.ucla.edu>
 
+	xalloc: add malloc-related function attributes
+	* lib/quotearg.h, lib/xalloc.h: Include stdlib.h, for
+	the benefit of _GL_ATTRIBUTE_RETURNS_NONNULL.
+	* lib/quotearg.h (clone_quoting_options):
+	* lib/xalloc.h (xmalloc, ximalloc, xzalloc, xizalloc, xcalloc)
+	(xicalloc, xrealloc, xirealloc, xireallocarray, x2realloc)
+	(x2nrealloc, xmemdup, ximemdup, xstrdup, xnmalloc, xcharalloc):
+	Add _GL_ATTRIBUTE_DALLOC_FREE and _GL_ATTRIBUTE_RETURNS_NONNULL
+	attributes as appropriate.
+
 	gnulib-common: update for gcc -Wmismatched-dealloc
 	* m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macros
 	_GL_ATTRIBUTE_DEALLOC and _GL_ATTRIBUTE_DEALLOC_FREE.  These can
diff --git a/lib/quotearg.h b/lib/quotearg.h
index bfc264289..ecef74f74 100644
--- a/lib/quotearg.h
+++ b/lib/quotearg.h
@@ -22,6 +22,7 @@
 # define QUOTEARG_H_ 1
 
 # include <stddef.h>
+# include <stdlib.h>
 
 /* Basic quoting styles.  For each style, an example is given on the
    input strings "simple", "\0 \t\n'\"\033?""?/\\", and "a:b", using
@@ -275,8 +276,9 @@ struct quoting_options;
 /* Allocate a new set of quoting options, with contents initially identical
    to O if O is not null, or to the default if O is null.
    It is the caller's responsibility to free the result.  */
-struct quoting_options *clone_quoting_options (struct quoting_options *o);
-
+struct quoting_options *clone_quoting_options (struct quoting_options *o)
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_RETURNS_NONNULL;
 /* Get the value of O's quoting style.  If O is null, use the default.  */
 enum quoting_style get_quoting_style (struct quoting_options const *o);
 
diff --git a/lib/xalloc.h b/lib/xalloc.h
index 70ef0971f..05e2daa71 100644
--- a/lib/xalloc.h
+++ b/lib/xalloc.h
@@ -19,6 +19,7 @@
 #define XALLOC_H_
 
 #include <stddef.h>
+#include <stdlib.h>
 #include <stdint.h>
 
 #if GNULIB_XALLOC
@@ -53,28 +54,50 @@ extern "C" {
 
 #if GNULIB_XALLOC
 
-void *xmalloc (size_t s) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
-void *ximalloc (idx_t s) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
-void *xzalloc (size_t s) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
-void *xizalloc (idx_t s) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
+void *xmalloc (size_t s)
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
+void *ximalloc (idx_t s)
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
+void *xzalloc (size_t s)
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
+void *xizalloc (idx_t s)
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
 void *xcalloc (size_t n, size_t s)
-  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2));
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
 void *xicalloc (idx_t n, idx_t s)
-  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2));
-void *xrealloc (void *p, size_t s) _GL_ATTRIBUTE_ALLOC_SIZE ((2));
-void *xirealloc (void *p, idx_t s) _GL_ATTRIBUTE_ALLOC_SIZE ((2));
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
+void *xrealloc (void *p, size_t s)
+  _GL_ATTRIBUTE_ALLOC_SIZE ((2));
+void *xirealloc (void *p, idx_t s)
+  _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
 void *xreallocarray (void *p, size_t n, size_t s)
-      _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
+  _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
 void *xireallocarray (void *p, idx_t n, idx_t s)
-      _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
-void *x2realloc (void *p, size_t *ps); /* superseded by xpalloc */
-void *x2nrealloc (void *p, size_t *pn, size_t s); /* superseded by xpalloc */
-void *xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s);
-void *xmemdup (void const *p, size_t s) _GL_ATTRIBUTE_ALLOC_SIZE ((2));
-void *ximemdup (void const *p, idx_t s) _GL_ATTRIBUTE_ALLOC_SIZE ((2));
-char *ximemdup0 (void const *p, idx_t s) _GL_ATTRIBUTE_MALLOC;
+  _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)) _GL_ATTRIBUTE_RETURNS_NONNULL;
+void *x2realloc (void *p, size_t *ps) /* superseded by xpalloc */
+  _GL_ATTRIBUTE_RETURNS_NONNULL;
+void *x2nrealloc (void *p, size_t *pn, size_t s) /* superseded by xpalloc */
+  _GL_ATTRIBUTE_RETURNS_NONNULL;
+void *xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s)
+  _GL_ATTRIBUTE_RETURNS_NONNULL;
+void *xmemdup (void const *p, size_t s)
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
+void *ximemdup (void const *p, idx_t s)
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
+char *ximemdup0 (void const *p, idx_t s)
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_RETURNS_NONNULL;
 char *xstrdup (char const *str)
-      _GL_ATTRIBUTE_MALLOC;
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_RETURNS_NONNULL;
 
 /* In the following macros, T must be an elementary or structure/union or
    typedef'ed type, or a pointer to such a type.  To apply one of the
@@ -106,7 +129,8 @@ char *xstrdup (char const *str)
    dynamically, with error checking.  S must be nonzero.  */
 
 XALLOC_INLINE void *xnmalloc (size_t n, size_t s)
-                    _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2));
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
 XALLOC_INLINE void *
 xnmalloc (size_t n, size_t s)
 {
@@ -118,7 +142,7 @@ xnmalloc (size_t n, size_t s)
    objects each of S bytes, with error checking.  S must be nonzero.  */
 
 XALLOC_INLINE void *xnrealloc (void *p, size_t n, size_t s)
-                    _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
+  _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
 XALLOC_INLINE void *
 xnrealloc (void *p, size_t n, size_t s)
 {
@@ -129,7 +153,8 @@ xnrealloc (void *p, size_t n, size_t s)
    except it returns char *.  */
 
 XALLOC_INLINE char *xcharalloc (size_t n)
-                    _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
+  _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+  _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
 XALLOC_INLINE char *
 xcharalloc (size_t n)
 {
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 6/6] doc: C2X -> C2x
  2021-07-31 19:01 [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Paul Eggert
                   ` (3 preceding siblings ...)
  2021-07-31 19:01 ` [PATCH 5/6] xalloc: add malloc-related function attributes Paul Eggert
@ 2021-07-31 19:01 ` Paul Eggert
  2021-08-01 13:38 ` [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Bruno Haible
  5 siblings, 0 replies; 7+ messages in thread
From: Paul Eggert @ 2021-07-31 19:01 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

---
 ChangeLog                     | 12 ++++++------
 doc/attribute.texi            |  6 +++---
 doc/posix-headers/assert.texi |  2 +-
 doc/verify.texi               |  4 ++--
 lib/attribute.h               |  2 +-
 lib/verify.h                  |  4 ++--
 6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 00224486f..e35192a9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11435,7 +11435,7 @@
 2020-05-03  Paul Eggert  <eggert@cs.ucla.edu>
 
 	attribute: new module
-	This simplifies use of GCC and C2X attributes like ‘deprecated’.
+	This simplifies use of GCC and C2x attributes like ‘deprecated’.
 	* MODULES.html.sh: Add attribute.
 	* doc/attribute.texi, lib/attribute.h, modules/attribute: New files.
 	* doc/gnulib.texi (Particular Modules): Add Attributes.
@@ -11446,7 +11446,7 @@
 	Include attribute.h, and let it define FALLTHROUGH.
 	* lib/bitset/base.h, lib/c-stack.c (__attribute__): Remove macro.
 	* lib/bitset/base.h (ATTRIBUTE_UNUSED): Define in terms of
-	_GL_ATTRIBUTE_MAYBE_UNUSED, for forwards compatibility to C2X.
+	_GL_ATTRIBUTE_MAYBE_UNUSED, for forwards compatibility to C2x.
 	* lib/dfa.c (FALLTHROUGH): Define consistently with gl_COMMON_BODY.
 	This is a copy since Gawk doesn’t use Gnulib.
 	* lib/di-set.h (_GL_ATTRIBUTE_NONNULL): Remove definition that
@@ -11461,7 +11461,7 @@
 	* lib/gl_list.h, lib/gl_map.h, lib/gl_omap.h, lib/gl_oset.h:
 	* lib/gl_set.h: Prefer _GL_ATTRIBUTE_NODISCARD to an ifdeffed
 	__attribute__ ((__warn_unused_result__)), for forward
-	compatibility to C2X.
+	compatibility to C2x.
 	* lib/hash.h (_GL_ATTRIBUTE_WUR): Remove.  All uses replaced by
 	_GL_ATTRIBUTE_NODISCARD.
 	(_GL_ATTRIBUTE_DEPRECATED): Remove, since gl_COMMON_BODY defines it.
@@ -18511,14 +18511,14 @@
 	* lib/verify.h (verify_true): Remove.
 	* tests/test-verify.c (item): Test verify_expr, not verify_true.
 
-	Support C2X and C++17 static_assert
-	C2X and C++17 finally added support for a simple, single-argument
+	Support C2x and C++17 static_assert
+	C2x and C++17 finally added support for a simple, single-argument
 	‘static_assert’ that implements what the Gnulib ‘verify’ macro was
 	doing back in 2005.  Implement static_assert on older platforms.
 	The only remaining advantage of ‘verify’ is a shorter name.
 	* doc/posix-headers/assert.texi (assert.h):
 	* doc/verify.texi (Compile-time Assertions):
-	Modernize for C2X and C++17.
+	Modernize for C2x and C++17.
 	* lib/verify.h (_GL_HAVE__STATIC_ASSERT1, _GL_HAVE_STATIC_ASSERT1):
 	New macros.
 	(_GL_HAVE__STATIC_ASSERT): Remove.
diff --git a/doc/attribute.texi b/doc/attribute.texi
index 983dfc350..815ed01ec 100644
--- a/doc/attribute.texi
+++ b/doc/attribute.texi
@@ -30,7 +30,7 @@ extern char *crypt (char const *, char const *)
 
 @noindent
 @code{NODISCARD} expands to @code{[[nodiscard]]} if the compiler
-supports this C2X syntax, otherwise to
+supports this C2x syntax, otherwise to
 @code{__attribute__ ((__warn_unused_result__))} if the compiler
 is a recent-enough GCC or GCC-like compiler, otherwise to nothing.
 @code{ATTRIBUTE_NOTHROW} expands to @code{__attribute__
@@ -41,11 +41,11 @@ compiler, and to nothing otherwise.  Similarly for
 recent-enough GCC, and to nothing otherwise.
 
 Most of these attribute names begin with @code{ATTRIBUTE_}.
-A few do not, because they are part of C2X and their
+A few do not, because they are part of C2x and their
 names are not likely to clash with other macro names.
 These macros are @code{DEPRECATED}, @code{FALLTHROUGH},
 @code{MAYBE_UNUSED}, and @code{NODISCARD}, which can
-be defined to @code{[[deprecated]]} etc.@: on C2X platforms.
+be defined to @code{[[deprecated]]} etc.@: on C2x platforms.
 Also, these exceptional macros should be placed at the start of
 function declarations, whereas the @code{ATTRIBUTE_*} macros can be
 placed at the end.
diff --git a/doc/posix-headers/assert.texi b/doc/posix-headers/assert.texi
index 28ddd1a59..3392a1691 100644
--- a/doc/posix-headers/assert.texi
+++ b/doc/posix-headers/assert.texi
@@ -13,7 +13,7 @@ Portability problems fixed by Gnulib:
 On older platforms @code{static_assert} and @code{_Static_assert} do
 not allow the second string-literal argument to be omitted.  For
 example, GCC versions before 9.1 do not support the single-argument
-@code{static_assert} that was standardized by C2X and C++17.
+@code{static_assert} that was standardized by C2x and C++17.
 @item
 Even-older platforms do not support @code{static_assert} or
 @code{_Static_assert} at all.  For example, GCC versions before 4.6 do
diff --git a/doc/verify.texi b/doc/verify.texi
index 42ce9b03d..8e2c19fa8 100644
--- a/doc/verify.texi
+++ b/doc/verify.texi
@@ -51,7 +51,7 @@ integer constant expression, then a compiler might reject a usage like
 @samp{verify (@var{V});} even when @var{V} is
 nonzero.
 
-Although the standard @code{assert} macro is a runtime test, C2X
+Although the standard @code{assert} macro is a runtime test, C2x
 specifies a builtin @code{_Static_assert (@var{V})},
 its @file{assert.h} header has a similar macro
 named @code{static_assert}, and C++17 has a similar
@@ -61,7 +61,7 @@ within a @code{struct} or @code{union} specifier, in place of an
 ordinary member declaration.  Second, they allow the programmer to
 specify, as an optional second argument, a compile-time diagnostic as
 a string literal.  If your program is not intended to be portable to
-compilers that lack C2X or C++17 @code{static_assert}, the only
+compilers that lack C2x or C++17 @code{static_assert}, the only
 advantage of @code{verify} is that its name is a bit shorter.
 
 The @file{verify.h} header defines one more macro, @code{assume
diff --git a/lib/attribute.h b/lib/attribute.h
index 6d3c04c07..80a23f550 100644
--- a/lib/attribute.h
+++ b/lib/attribute.h
@@ -32,7 +32,7 @@
 
 
 /* This file defines two types of attributes:
-   * C2X standard attributes.  These have macro names that do not begin with
+   * C2x standard attributes.  These have macro names that do not begin with
      'ATTRIBUTE_'.
    * Selected GCC attributes; see:
      https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
diff --git a/lib/verify.h b/lib/verify.h
index 3485a7e69..a8ca59b09 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -25,7 +25,7 @@
    works as per C11.  This is supported by GCC 4.6.0+ and by clang 4+.
 
    Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as
-   per C2X.  This is supported by GCC 9.1+.
+   per C2x.  This is supported by GCC 9.1+.
 
    Support compilers claiming conformance to the relevant standard,
    and also support GCC when not pedantic.  If we were willing to slow
@@ -202,7 +202,7 @@ template <int w>
 
    This macro requires three or more arguments but uses at most the first
    two, so that the _Static_assert macro optionally defined below supports
-   both the C11 two-argument syntax and the C2X one-argument syntax.
+   both the C11 two-argument syntax and the C2x one-argument syntax.
 
    Unfortunately, unlike C11, this implementation must appear as an
    ordinary declaration, and cannot appear inside struct { ... }.  */
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH
  2021-07-31 19:01 [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Paul Eggert
                   ` (4 preceding siblings ...)
  2021-07-31 19:01 ` [PATCH 6/6] doc: C2X -> C2x Paul Eggert
@ 2021-08-01 13:38 ` Bruno Haible
  5 siblings, 0 replies; 7+ messages in thread
From: Bruno Haible @ 2021-08-01 13:38 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

> +	limits-h: add BOOL_MAX, BOOL_WIDTH

2021-08-01  Bruno Haible  <bruno@clisp.org>

	limits-h tests: Add tests for BOOL_MAX and BOOL_WIDTH.
	* tests/test-limits-h.c (bool_attrs): New variable.
	Check value of BOOL_MAX.

diff --git a/tests/test-limits-h.c b/tests/test-limits-h.c
index 4144013..f3394c1 100644
--- a/tests/test-limits-h.c
+++ b/tests/test-limits-h.c
@@ -110,6 +110,11 @@ verify_width (ULONG_WIDTH, 0, ULONG_MAX);
 verify_width (LLONG_WIDTH, LLONG_MIN, LLONG_MAX);
 verify_width (ULLONG_WIDTH, 0, ULLONG_MAX);
 
+/* Macros specified by C2x.  */
+
+int bool_attrs[] = { BOOL_MAX, BOOL_WIDTH };
+verify (BOOL_MAX == (((1U << (BOOL_WIDTH - 1)) - 1) * 2) + 1);
+
 int
 main (void)
 {



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-08-01 13:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-31 19:01 [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Paul Eggert
2021-07-31 19:01 ` [PATCH 2/6] manywarnings: document GCC 11 warnings Paul Eggert
2021-07-31 19:01 ` [PATCH 3/6] gnulib-common: update for C2x 2020-12-11 draft Paul Eggert
2021-07-31 19:01 ` [PATCH 4/6] gnulib-common: update for gcc -Wmismatched-dealloc Paul Eggert
2021-07-31 19:01 ` [PATCH 5/6] xalloc: add malloc-related function attributes Paul Eggert
2021-07-31 19:01 ` [PATCH 6/6] doc: C2X -> C2x Paul Eggert
2021-08-01 13:38 ` [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).