C23 introduced the longstanding C++ convention that a function parameter’s identifier can be omitted, meaning that the parameter is unnamed. This is clearer than [[maybe_unused]], as it means the parameter is definitely (not maybe) unused. When applicable, prefer this new macro to _GL_ATTRIBUTE_MAYBE_UNUSED. * Makefile (config_h_MACROS2): Add _GL_UNNAMED. * lib/se-context.in.h, lib/se-label.in.h, lib/se-selinux.in.h: * lib/textstyle.in.h: Define a backup _GL_UNNAMED macro instead of defining a backup _GL_ATTRIBUTE_MAYBE_UNUSED macro, even though I’m unsure why any backup macro definition is needed, as other gnulib-common macros are used without defining them. * m4/gnulib-common.m4 (_GL_UNNAMED): New macro. All uses of _GL_ATTRIBUTE_MAYBE_UNUSED replaced to use the new macro, when that makes sense. --- ChangeLog | 18 +++++ Makefile | 1 + lib/gl_anylinked_list2.h | 5 +- lib/gl_anytree_list2.h | 15 ++-- 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/se-context.in.h | 45 +++++------ lib/se-label.in.h | 42 +++++----- lib/se-selinux.in.h | 101 ++++++++++------------- lib/textstyle.in.h | 169 +++++++++++++++++++-------------------- lib/unistr.in.h | 4 +- m4/gnulib-common.m4 | 19 ++++- tests/test-hamt.c | 3 +- 17 files changed, 218 insertions(+), 216 deletions(-)
diff --git a/ChangeLog b/ChangeLog index 161f0ce585..d24d42af21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2025-12-23 Paul Eggert <[email protected]> + + New C macro _GL_UNNAMED + C23 introduced the longstanding C++ convention that a function + parameter’s identifier can be omitted, meaning that the parameter + is unnamed. This is clearer than [[maybe_unused]], as it means + the parameter is definitely (not maybe) unused. When applicable, + prefer this new macro to _GL_ATTRIBUTE_MAYBE_UNUSED. + * Makefile (config_h_MACROS2): Add _GL_UNNAMED. + * lib/se-context.in.h, lib/se-label.in.h, lib/se-selinux.in.h: + * lib/textstyle.in.h: Define a backup _GL_UNNAMED macro instead of + defining a backup _GL_ATTRIBUTE_MAYBE_UNUSED macro, even though + I’m unsure why any backup macro definition is needed, + as other gnulib-common macros are used without defining them. + * m4/gnulib-common.m4 (_GL_UNNAMED): New macro. + All uses of _GL_ATTRIBUTE_MAYBE_UNUSED replaced to use the new macro, + when that makes sense. + 2025-12-20 Paul Eggert <[email protected]> Fix [[unsequenced]] and [[reproducible]] confusion diff --git a/Makefile b/Makefile index 0ffc677946..eb88960af6 100644 --- a/Makefile +++ b/Makefile @@ -243,6 +243,7 @@ config_h_MACROS2 = \ _GL_ATTRIBUTE_UNSEQUENCED \ _GL_ATTRIBUTE_UNUSED \ _GL_UNUSED_LABEL \ + _GL_UNNAMED \ _GL_ATTRIBUTE_CAPABILITY_TYPE \ _GL_ATTRIBUTE_ACQUIRE_CAPABILITY \ _GL_ATTRIBUTE_RELEASE_CAPABILITY \ diff --git a/lib/gl_anylinked_list2.h b/lib/gl_anylinked_list2.h index 248910dc2a..61212d4532 100644 --- a/lib/gl_anylinked_list2.h +++ b/lib/gl_anylinked_list2.h @@ -166,8 +166,7 @@ gl_linked_size (gl_list_t list) } static const void * _GL_ATTRIBUTE_PURE -gl_linked_node_value (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list, - gl_list_node_t node) +gl_linked_node_value (gl_list_t _GL_UNNAMED (list), gl_list_node_t node) { return node->value; } @@ -1017,7 +1016,7 @@ gl_linked_iterator_next (gl_list_iterator_t *iterator, } static void -gl_linked_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_iterator_t *iterator) +gl_linked_iterator_free (gl_list_iterator_t *_GL_UNNAMED (iterator)) { } diff --git a/lib/gl_anytree_list2.h b/lib/gl_anytree_list2.h index ad9ef8e247..9ee778ca72 100644 --- a/lib/gl_anytree_list2.h +++ b/lib/gl_anytree_list2.h @@ -60,8 +60,7 @@ gl_tree_size (gl_list_t list) } static const void * _GL_ATTRIBUTE_PURE -gl_tree_node_value (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list, - gl_list_node_t node) +gl_tree_node_value (gl_list_t _GL_UNNAMED (list), gl_list_node_t node) { return node->value; } @@ -103,8 +102,7 @@ gl_tree_node_nx_set_value (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list, } static gl_list_node_t _GL_ATTRIBUTE_PURE -gl_tree_next_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list, - gl_list_node_t node) +gl_tree_next_node (gl_list_t _GL_UNNAMED (list), gl_list_node_t node) { if (node->right != NULL) { @@ -122,8 +120,7 @@ gl_tree_next_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list, } static gl_list_node_t _GL_ATTRIBUTE_PURE -gl_tree_previous_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list, - gl_list_node_t node) +gl_tree_previous_node (gl_list_t _GL_UNNAMED (list), gl_list_node_t node) { if (node->left != NULL) { @@ -141,7 +138,7 @@ gl_tree_previous_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list, } static gl_list_node_t _GL_ATTRIBUTE_PURE -gl_tree_first_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list) +gl_tree_first_node (gl_list_t list) { gl_list_node_t node = list->root; @@ -154,7 +151,7 @@ gl_tree_first_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list) } static gl_list_node_t _GL_ATTRIBUTE_PURE -gl_tree_last_node (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_t list) +gl_tree_last_node (gl_list_t list) { gl_list_node_t node = list->root; @@ -659,7 +656,7 @@ gl_tree_iterator_next (gl_list_iterator_t *iterator, } static void -gl_tree_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_iterator_t *iterator) +gl_tree_iterator_free (gl_list_iterator_t *_GL_UNNAMED (iterator)) { } diff --git a/lib/gl_anytree_omap.h b/lib/gl_anytree_omap.h index 757eb83c17..16ac31896e 100644 --- a/lib/gl_anytree_omap.h +++ b/lib/gl_anytree_omap.h @@ -296,6 +296,6 @@ gl_tree_iterator_next (gl_omap_iterator_t *iterator, } static void -gl_tree_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_omap_iterator_t *iterator) +gl_tree_iterator_free (gl_omap_iterator_t *_GL_UNNAMED (iterator)) { } diff --git a/lib/gl_anytree_oset.h b/lib/gl_anytree_oset.h index 4083b9b545..abe8f8f76a 100644 --- a/lib/gl_anytree_oset.h +++ b/lib/gl_anytree_oset.h @@ -432,6 +432,6 @@ gl_tree_iterator_next (gl_oset_iterator_t *iterator, const void **eltp) } static void -gl_tree_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_oset_iterator_t *iterator) +gl_tree_iterator_free (gl_oset_iterator_t *_GL_UNNAMED (iterator)) { } diff --git a/lib/gl_array_list.c b/lib/gl_array_list.c index 385cece876..b43378aa71 100644 --- a/lib/gl_array_list.c +++ b/lib/gl_array_list.c @@ -504,7 +504,7 @@ gl_array_iterator_next (gl_list_iterator_t *iterator, } static void -gl_array_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_iterator_t *iterator) +gl_array_iterator_free (gl_list_iterator_t *_GL_UNNAMED (iterator)) { } diff --git a/lib/gl_array_omap.c b/lib/gl_array_omap.c index 4c9eb7ea9a..bceb9c2581 100644 --- a/lib/gl_array_omap.c +++ b/lib/gl_array_omap.c @@ -360,7 +360,7 @@ gl_array_iterator_next (gl_omap_iterator_t *iterator, } static void -gl_array_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_omap_iterator_t *iterator) +gl_array_iterator_free (gl_omap_iterator_t *_GL_UNNAMED (iterator)) { } diff --git a/lib/gl_array_oset.c b/lib/gl_array_oset.c index ed1aea666e..8330566d37 100644 --- a/lib/gl_array_oset.c +++ b/lib/gl_array_oset.c @@ -476,7 +476,7 @@ gl_array_iterator_next (gl_oset_iterator_t *iterator, const void **eltp) } static void -gl_array_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_oset_iterator_t *iterator) +gl_array_iterator_free (gl_oset_iterator_t *_GL_UNNAMED (iterator)) { } diff --git a/lib/gl_carray_list.c b/lib/gl_carray_list.c index 5a020fa6e0..bf4c07cc8b 100644 --- a/lib/gl_carray_list.c +++ b/lib/gl_carray_list.c @@ -677,7 +677,7 @@ gl_carray_iterator_next (gl_list_iterator_t *iterator, } static void -gl_carray_iterator_free (_GL_ATTRIBUTE_MAYBE_UNUSED gl_list_iterator_t *iterator) +gl_carray_iterator_free (gl_list_iterator_t *_GL_UNNAMED (iterator)) { } diff --git a/lib/se-context.in.h b/lib/se-context.in.h index c2c2d7a30d..4d9f15fa57 100644 --- a/lib/se-context.in.h +++ b/lib/se-context.in.h @@ -19,8 +19,7 @@ #ifndef SELINUX_CONTEXT_H #define SELINUX_CONTEXT_H -/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, - _GL_ATTRIBUTE_MAYBE_UNUSED. */ +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_UNNAMED. */ #if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif @@ -32,55 +31,49 @@ _GL_INLINE_HEADER_BEGIN # define SE_CONTEXT_INLINE _GL_INLINE #endif -/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if - the entity is not used. The compiler should not warn if the entity is not - used. */ -#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED -# if 0 /* no GCC or clang version supports this yet */ -# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] -# elif defined __GNUC__ || defined __clang__ -# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__)) +/* _GL_UNNAMED (ID) is the "name" of an unnamed function parameter. */ +#ifndef _GL_UNNAMED +# if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 202311 \ + && !defined __cplusplus) +# define _GL_UNNAMED(id) unnamed_##id _GL_ATTRIBUTE_UNUSED # else -# define _GL_ATTRIBUTE_MAYBE_UNUSED +# define _GL_UNNAMED(id) # endif #endif + typedef int context_t; SE_CONTEXT_INLINE context_t -context_new (_GL_ATTRIBUTE_MAYBE_UNUSED char const *s) +context_new (char const *_GL_UNNAMED (s)) { errno = ENOTSUP; return 0; } SE_CONTEXT_INLINE char * -context_str (_GL_ATTRIBUTE_MAYBE_UNUSED context_t con) +context_str (context_t _GL_UNNAMED (con)) { errno = ENOTSUP; return (void *) 0; } -SE_CONTEXT_INLINE void context_free (_GL_ATTRIBUTE_MAYBE_UNUSED context_t c) {} +SE_CONTEXT_INLINE void context_free (context_t _GL_UNNAMED (c)) {} SE_CONTEXT_INLINE int -context_user_set (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc, - _GL_ATTRIBUTE_MAYBE_UNUSED char const *s) +context_user_set (context_t _GL_UNNAMED (sc), char const *_GL_UNNAMED (s)) { errno = ENOTSUP; return -1; } SE_CONTEXT_INLINE int -context_role_set (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc, - _GL_ATTRIBUTE_MAYBE_UNUSED char const *s) +context_role_set (context_t _GL_UNNAMED (sc), char const *_GL_UNNAMED (s)) { errno = ENOTSUP; return -1; } SE_CONTEXT_INLINE int -context_range_set (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc, - _GL_ATTRIBUTE_MAYBE_UNUSED char const *s) +context_range_set (context_t _GL_UNNAMED (sc), char const *_GL_UNNAMED (s)) { errno = ENOTSUP; return -1; } SE_CONTEXT_INLINE int -context_type_set (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc, - _GL_ATTRIBUTE_MAYBE_UNUSED char const *s) +context_type_set (context_t _GL_UNNAMED (sc), char const *_GL_UNNAMED (s)) { errno = ENOTSUP; return -1; } SE_CONTEXT_INLINE char * -context_type_get (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc) +context_type_get (context_t _GL_UNNAMED (sc)) { errno = ENOTSUP; return (void *) 0; } SE_CONTEXT_INLINE char * -context_range_get (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc) +context_range_get (context_t _GL_UNNAMED (sc)) { errno = ENOTSUP; return (void *) 0; } SE_CONTEXT_INLINE char * -context_role_get (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc) +context_role_get (context_t _GL_UNNAMED (sc)) { errno = ENOTSUP; return (void *) 0; } SE_CONTEXT_INLINE char * -context_user_get (_GL_ATTRIBUTE_MAYBE_UNUSED context_t sc) +context_user_get (context_t _GL_UNNAMED (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 7ff191ab39..dc751a2f18 100644 --- a/lib/se-label.in.h +++ b/lib/se-label.in.h @@ -19,8 +19,7 @@ #ifndef SELINUX_LABEL_H #define SELINUX_LABEL_H -/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, - _GL_ATTRIBUTE_MAYBE_UNUSED. */ +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_UNNAMED. */ #if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif @@ -33,16 +32,13 @@ _GL_INLINE_HEADER_BEGIN # define SE_LABEL_INLINE _GL_INLINE #endif -/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if - the entity is not used. The compiler should not warn if the entity is not - used. */ -#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED -# if 0 /* no GCC or clang version supports this yet */ -# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] -# elif defined __GNUC__ || defined __clang__ -# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__)) +/* _GL_UNNAMED (ID) is the "name" of an unnamed function parameter. */ +#ifndef _GL_UNNAMED +# if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 202311 \ + && !defined __cplusplus) +# define _GL_UNNAMED(id) unnamed_##id _GL_ATTRIBUTE_UNUSED # else -# define _GL_ATTRIBUTE_MAYBE_UNUSED +# define _GL_UNNAMED(id) # endif #endif @@ -51,27 +47,27 @@ _GL_INLINE_HEADER_BEGIN struct selabel_handle; SE_LABEL_INLINE int -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) +selabel_lookup (struct selabel_handle *_GL_UNNAMED (hnd), + char **_GL_UNNAMED (context), + char const *_GL_UNNAMED (key), + int _GL_UNNAMED (type)) { errno = ENOTSUP; return -1; } SE_LABEL_INLINE int -selabel_lookup_raw (_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) +selabel_lookup_raw (struct selabel_handle *_GL_UNNAMED (hnd), + char **_GL_UNNAMED (context), + char const *_GL_UNNAMED (key), + int _GL_UNNAMED (type)) { errno = ENOTSUP; return -1; } SE_LABEL_INLINE struct selabel_handle * -selabel_open (_GL_ATTRIBUTE_MAYBE_UNUSED int backend, - _GL_ATTRIBUTE_MAYBE_UNUSED struct selinux_opt *options, - _GL_ATTRIBUTE_MAYBE_UNUSED unsigned nopt) +selabel_open (int _GL_UNNAMED (backend), + struct selinux_opt *_GL_UNNAMED (options), + unsigned _GL_UNNAMED (nopt)) { errno = ENOTSUP; return 0; } SE_LABEL_INLINE void -selabel_close (_GL_ATTRIBUTE_MAYBE_UNUSED struct selabel_handle *hnd) +selabel_close (struct selabel_handle *_GL_UNNAMED (hnd)) { errno = ENOTSUP; } _GL_INLINE_HEADER_END diff --git a/lib/se-selinux.in.h b/lib/se-selinux.in.h index 6ddd273b2a..736400c35f 100644 --- a/lib/se-selinux.in.h +++ b/lib/se-selinux.in.h @@ -27,8 +27,7 @@ # if !defined _@GUARD_PREFIX@_SELINUX_SELINUX_H # define _@GUARD_PREFIX@_SELINUX_SELINUX_H -/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, - _GL_ATTRIBUTE_MAYBE_UNUSED. */ +/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_UNNAMED. */ # if !_GL_CONFIG_H_INCLUDED # error "Please include config.h first." # endif @@ -41,16 +40,13 @@ _GL_INLINE_HEADER_BEGIN # define SE_SELINUX_INLINE _GL_INLINE # endif -/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if - the entity is not used. The compiler should not warn if the entity is not - used. */ -# ifndef _GL_ATTRIBUTE_MAYBE_UNUSED -# if 0 /* no GCC or clang version supports this yet */ -# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] -# elif defined __GNUC__ || defined __clang__ -# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__)) +/* _GL_UNNAMED (ID) is the "name" of an unnamed function parameter. */ +# ifndef _GL_UNNAMED +# if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 202311 \ + && !defined __cplusplus) +# define _GL_UNNAMED(id) unnamed_##id _GL_ATTRIBUTE_UNUSED # else -# define _GL_ATTRIBUTE_MAYBE_UNUSED +# define _GL_UNNAMED(id) # endif # endif @@ -61,108 +57,97 @@ struct selinux_opt; # define is_selinux_enabled() 0 SE_SELINUX_INLINE int -getcon (_GL_ATTRIBUTE_MAYBE_UNUSED char **con) +getcon (char **_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -getcon_raw (_GL_ATTRIBUTE_MAYBE_UNUSED char **con) +getcon_raw (char **_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE void -freecon (_GL_ATTRIBUTE_MAYBE_UNUSED char *con) {} +freecon (char *_GL_UNNAMED (con)) {} SE_SELINUX_INLINE int -getfscreatecon (_GL_ATTRIBUTE_MAYBE_UNUSED char **con) +getfscreatecon (char **_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -getfscreatecon_raw (_GL_ATTRIBUTE_MAYBE_UNUSED char **con) +getfscreatecon_raw (char **_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -setfscreatecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con) +setfscreatecon (char const *_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -setfscreatecon_raw (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con) +setfscreatecon_raw (char const *_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -matchpathcon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file, - _GL_ATTRIBUTE_MAYBE_UNUSED mode_t m, - _GL_ATTRIBUTE_MAYBE_UNUSED char **con) +matchpathcon (char const *_GL_UNNAMED (file), mode_t _GL_UNNAMED (m), + char **_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -getfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file, - _GL_ATTRIBUTE_MAYBE_UNUSED char **con) +getfilecon (char const *_GL_UNNAMED (file), char **_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -getfilecon_raw (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file, - _GL_ATTRIBUTE_MAYBE_UNUSED char **con) +getfilecon_raw (char const *_GL_UNNAMED (file), char **_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -lgetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file, - _GL_ATTRIBUTE_MAYBE_UNUSED char **con) +lgetfilecon (char const *_GL_UNNAMED (file), char **_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -lgetfilecon_raw (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file, - _GL_ATTRIBUTE_MAYBE_UNUSED char **con) +lgetfilecon_raw (char const *_GL_UNNAMED (file), char **_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -fgetfilecon (int fd,_GL_ATTRIBUTE_MAYBE_UNUSED char **con) +fgetfilecon (int _GL_UNNAMED (fd), char **_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -fgetfilecon_raw (int fd,_GL_ATTRIBUTE_MAYBE_UNUSED char **con) +fgetfilecon_raw (int _GL_UNNAMED (fd), char **_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -setfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file, - _GL_ATTRIBUTE_MAYBE_UNUSED char const *con) +setfilecon (char const *_GL_UNNAMED (file), char const *_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -setfilecon_raw (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file, - _GL_ATTRIBUTE_MAYBE_UNUSED char const *con) +setfilecon_raw (char const *_GL_UNNAMED (file), char const *_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -lsetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file, - _GL_ATTRIBUTE_MAYBE_UNUSED char const *con) +lsetfilecon (char const *_GL_UNNAMED (file), char const *_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -lsetfilecon_raw (_GL_ATTRIBUTE_MAYBE_UNUSED char const *file, - _GL_ATTRIBUTE_MAYBE_UNUSED char const *con) +lsetfilecon_raw (char const *_GL_UNNAMED (file), char const *_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -fsetfilecon (_GL_ATTRIBUTE_MAYBE_UNUSED int fd, - _GL_ATTRIBUTE_MAYBE_UNUSED char const *con) +fsetfilecon (int _GL_UNNAMED (fd), char const *_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -fsetfilecon_raw (_GL_ATTRIBUTE_MAYBE_UNUSED int fd, - _GL_ATTRIBUTE_MAYBE_UNUSED char const *con) +fsetfilecon_raw (int _GL_UNNAMED (fd), char const *_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -security_check_context (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con) +security_check_context (char const *_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -security_check_context_raw (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con) +security_check_context_raw (char const *_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -setexeccon (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con) +setexeccon (char const *_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -setexeccon_raw (_GL_ATTRIBUTE_MAYBE_UNUSED char const *con) +setexeccon_raw (char const *_GL_UNNAMED (con)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -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) +security_compute_create (char const *_GL_UNNAMED (scon), + char const *_GL_UNNAMED (tcon), + security_class_t _GL_UNNAMED (tclass), + char **_GL_UNNAMED (newcon)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE int -security_compute_create_raw (_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) +security_compute_create_raw (char const *_GL_UNNAMED (scon), + char const *_GL_UNNAMED (tcon), + security_class_t _GL_UNNAMED (tclass), + char **_GL_UNNAMED (newcon)) { errno = ENOTSUP; return -1; } SE_SELINUX_INLINE security_class_t -string_to_security_class (char const *name) +string_to_security_class (char const *_GL_UNNAMED (name)) { errno = ENOTSUP; return 0; } SE_SELINUX_INLINE int -matchpathcon_init_prefix (_GL_ATTRIBUTE_MAYBE_UNUSED char const *path, - _GL_ATTRIBUTE_MAYBE_UNUSED char const *prefix) +matchpathcon_init_prefix (char const *_GL_UNNAMED (path), + char const *_GL_UNNAMED (prefix)) { errno = ENOTSUP; return -1; } # define GNULIB_defined_security_types 1 diff --git a/lib/textstyle.in.h b/lib/textstyle.in.h index 662c2dda41..c6711af74a 100644 --- a/lib/textstyle.in.h +++ b/lib/textstyle.in.h @@ -30,7 +30,7 @@ #ifndef _TEXTSTYLE_H #define _TEXTSTYLE_H -/* This file uses _GL_ATTRIBUTE_MAYBE_UNUSED, HAVE_TCDRAIN. */ +/* This file uses _GL_UNNAMED, HAVE_TCDRAIN. */ #if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif @@ -59,16 +59,13 @@ # endif #endif -/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if - the entity is not used. The compiler should not warn if the entity is not - used. */ -#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED -# if 0 /* no GCC or clang version supports this yet */ -# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] -# elif defined __GNUC__ || defined __clang__ -# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__)) +/* _GL_UNNAMED (ID) is the "name" of an unnamed function parameter. */ +#ifndef _GL_UNNAMED +# if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 202311 \ + && !defined __cplusplus) +# define _GL_UNNAMED(id) unnamed_##id _GL_ATTRIBUTE_UNUSED # else -# define _GL_ATTRIBUTE_MAYBE_UNUSED +# define _GL_UNNAMED(id) # endif #endif @@ -196,43 +193,43 @@ typedef ostream_t styled_ostream_t; #define styled_ostream_free ostream_free static inline void -styled_ostream_begin_use_class (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *classname) +styled_ostream_begin_use_class (styled_ostream_t _GL_UNNAMED (stream), + const char *_GL_UNNAMED (classname)) { } static inline void -styled_ostream_end_use_class (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *classname) +styled_ostream_end_use_class (styled_ostream_t _GL_UNNAMED (stream), + const char *_GL_UNNAMED (classname)) { } static inline const char * -styled_ostream_get_hyperlink_ref (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t stream) +styled_ostream_get_hyperlink_ref (styled_ostream_t _GL_UNNAMED (stream)) { return NULL; } static inline const char * -styled_ostream_get_hyperlink_id (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t stream) +styled_ostream_get_hyperlink_id (styled_ostream_t _GL_UNNAMED (stream)) { return NULL; } static inline void -styled_ostream_set_hyperlink (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *ref, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *id) +styled_ostream_set_hyperlink (styled_ostream_t _GL_UNNAMED (stream), + const char *_GL_UNNAMED (ref), + const char *_GL_UNNAMED (id)) { } static inline void -styled_ostream_flush_to_current_style (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t stream) +styled_ostream_flush_to_current_style (styled_ostream_t _GL_UNNAMED (stream)) { } static inline bool -is_instance_of_styled_ostream (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t stream) +is_instance_of_styled_ostream (ostream_t _GL_UNNAMED (stream)) { return false; } @@ -258,7 +255,7 @@ file_ostream_create (FILE *fp) } static inline bool -is_instance_of_file_ostream (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t stream) +is_instance_of_file_ostream (ostream_t _GL_UNNAMED (stream)) { return true; } @@ -278,20 +275,20 @@ fd_ostream_get_descriptor (fd_ostream_t stream) } static inline const char * -fd_ostream_get_filename (_GL_ATTRIBUTE_MAYBE_UNUSED fd_ostream_t stream) +fd_ostream_get_filename (fd_ostream_t _GL_UNNAMED (stream)) { return NULL; } static inline bool -fd_ostream_is_buffered (_GL_ATTRIBUTE_MAYBE_UNUSED fd_ostream_t stream) +fd_ostream_is_buffered (fd_ostream_t _GL_UNNAMED (stream)) { return false; } static inline fd_ostream_t -fd_ostream_create (int fd, _GL_ATTRIBUTE_MAYBE_UNUSED const char *filename, - _GL_ATTRIBUTE_MAYBE_UNUSED bool buffered) +fd_ostream_create (int fd, const char *_GL_UNNAMED (filename), + bool _GL_UNNAMED (buffered)) { if (fd == 1) return stdout; @@ -359,90 +356,90 @@ typedef ostream_t term_ostream_t; #define term_ostream_free ostream_free static inline term_color_t -term_ostream_rgb_to_color (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED int red, - _GL_ATTRIBUTE_MAYBE_UNUSED int green, - _GL_ATTRIBUTE_MAYBE_UNUSED int blue) +term_ostream_rgb_to_color (term_ostream_t _GL_UNNAMED (stream), + int _GL_UNNAMED (red), + int _GL_UNNAMED (green), + int _GL_UNNAMED (blue)) { return COLOR_DEFAULT; } static inline term_color_t -term_ostream_get_color (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) +term_ostream_get_color (term_ostream_t _GL_UNNAMED (stream)) { return COLOR_DEFAULT; } static inline void -term_ostream_set_color (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED term_color_t color) +term_ostream_set_color (term_ostream_t _GL_UNNAMED (stream), + term_color_t _GL_UNNAMED (color)) { } static inline term_color_t -term_ostream_get_bgcolor (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) +term_ostream_get_bgcolor (term_ostream_t _GL_UNNAMED (stream)) { return COLOR_DEFAULT; } static inline void -term_ostream_set_bgcolor (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED term_color_t color) +term_ostream_set_bgcolor (term_ostream_t _GL_UNNAMED (stream), + term_color_t _GL_UNNAMED (color)) { } static inline term_weight_t -term_ostream_get_weight (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) +term_ostream_get_weight (term_ostream_t _GL_UNNAMED (stream)) { return WEIGHT_DEFAULT; } static inline void -term_ostream_set_weight (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED term_weight_t weight) +term_ostream_set_weight (term_ostream_t _GL_UNNAMED (stream), + term_weight_t _GL_UNNAMED (weight)) { } static inline term_posture_t -term_ostream_get_posture (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) +term_ostream_get_posture (term_ostream_t _GL_UNNAMED (stream)) { return POSTURE_DEFAULT; } static inline void -term_ostream_set_posture (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED term_posture_t posture) +term_ostream_set_posture (term_ostream_t _GL_UNNAMED (stream), + term_posture_t _GL_UNNAMED (posture)) { } static inline term_underline_t -term_ostream_get_underline (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) +term_ostream_get_underline (term_ostream_t _GL_UNNAMED (stream)) { return UNDERLINE_DEFAULT; } static inline void -term_ostream_set_underline (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED term_underline_t underline) +term_ostream_set_underline (term_ostream_t _GL_UNNAMED (stream), + term_underline_t _GL_UNNAMED (underline)) { } static inline const char * -term_ostream_get_hyperlink_ref (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) +term_ostream_get_hyperlink_ref (term_ostream_t _GL_UNNAMED (stream)) { return NULL; } static inline const char * -term_ostream_get_hyperlink_id (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) +term_ostream_get_hyperlink_id (term_ostream_t _GL_UNNAMED (stream)) { return NULL; } static inline void -term_ostream_set_hyperlink (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *ref, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *id) +term_ostream_set_hyperlink (term_ostream_t _GL_UNNAMED (stream), + const char *_GL_UNNAMED (ref), + const char *_GL_UNNAMED (id)) { } @@ -456,20 +453,20 @@ term_ostream_flush_to_current_style (term_ostream_t stream) #define term_ostream_get_filename fd_ostream_get_filename static inline ttyctl_t -term_ostream_get_tty_control (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) +term_ostream_get_tty_control (term_ostream_t _GL_UNNAMED (stream)) { return TTYCTL_NONE; } static inline ttyctl_t -term_ostream_get_effective_tty_control (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) +term_ostream_get_effective_tty_control (term_ostream_t _GL_UNNAMED (stream)) { return TTYCTL_NONE; } static inline term_ostream_t term_ostream_create (int fd, const char *filename, - _GL_ATTRIBUTE_MAYBE_UNUSED ttyctl_t tty_control) + ttyctl_t _GL_UNNAMED (tty_control)) { return fd_ostream_create (fd, filename, true); } @@ -485,7 +482,7 @@ typedef ostream_t memory_ostream_t; #define memory_ostream_free ostream_free static inline void -memory_ostream_contents (_GL_ATTRIBUTE_MAYBE_UNUSED memory_ostream_t stream, +memory_ostream_contents (memory_ostream_t _GL_UNNAMED (stream), const void **bufp, size_t *buflenp) { *bufp = NULL; @@ -501,7 +498,7 @@ memory_ostream_create (void) } static inline bool -is_instance_of_memory_ostream (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t stream) +is_instance_of_memory_ostream (ostream_t _GL_UNNAMED (stream)) { return false; } @@ -515,42 +512,42 @@ typedef ostream_t html_ostream_t; #define html_ostream_free ostream_free static inline void -html_ostream_begin_span (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *classname) +html_ostream_begin_span (html_ostream_t _GL_UNNAMED (stream), + const char *_GL_UNNAMED (classname)) { } static inline void -html_ostream_end_span (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *classname) +html_ostream_end_span (html_ostream_t _GL_UNNAMED (stream), + const char *_GL_UNNAMED (classname)) { } static inline const char * -html_ostream_get_hyperlink_ref (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t stream) +html_ostream_get_hyperlink_ref (html_ostream_t _GL_UNNAMED (stream)) { return NULL; } static inline void -html_ostream_set_hyperlink_ref (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t stream, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *ref) +html_ostream_set_hyperlink_ref (html_ostream_t _GL_UNNAMED (stream), + const char *_GL_UNNAMED (ref)) { } static inline void -html_ostream_flush_to_current_style (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t stream) +html_ostream_flush_to_current_style (html_ostream_t _GL_UNNAMED (stream)) { } static inline ostream_t -html_ostream_get_destination (_GL_ATTRIBUTE_MAYBE_UNUSED html_ostream_t stream) +html_ostream_get_destination (html_ostream_t _GL_UNNAMED (stream)) { return NULL; } static inline html_ostream_t -html_ostream_create (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t destination) +html_ostream_create (ostream_t _GL_UNNAMED (destination)) { /* Not supported without the real libtextstyle. */ abort (); @@ -558,7 +555,7 @@ html_ostream_create (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t destination) } static inline bool -is_instance_of_html_ostream (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t stream) +is_instance_of_html_ostream (ostream_t _GL_UNNAMED (stream)) { return false; } @@ -584,15 +581,15 @@ term_styled_ostream_get_destination (term_styled_ostream_t stream) } static inline const char * -term_styled_ostream_get_css_filename (_GL_ATTRIBUTE_MAYBE_UNUSED term_styled_ostream_t stream) +term_styled_ostream_get_css_filename (term_styled_ostream_t _GL_UNNAMED (stream)) { return NULL; } static inline term_styled_ostream_t term_styled_ostream_create (int fd, const char *filename, - _GL_ATTRIBUTE_MAYBE_UNUSED ttyctl_t tty_control, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *css_filename) + ttyctl_t _GL_UNNAMED (tty_control), + const char *_GL_UNNAMED (css_filename)) { return fd_ostream_create (fd, filename, true); } @@ -614,26 +611,26 @@ typedef styled_ostream_t html_styled_ostream_t; #define html_styled_ostream_flush_to_current_style styled_ostream_flush_to_current_style static inline ostream_t -html_styled_ostream_get_destination (_GL_ATTRIBUTE_MAYBE_UNUSED html_styled_ostream_t stream) +html_styled_ostream_get_destination (html_styled_ostream_t _GL_UNNAMED (stream)) { return NULL; } static inline html_ostream_t -html_styled_ostream_get_html_destination (_GL_ATTRIBUTE_MAYBE_UNUSED html_styled_ostream_t stream) +html_styled_ostream_get_html_destination (html_styled_ostream_t _GL_UNNAMED (stream)) { return NULL; } static inline const char * -html_styled_ostream_get_css_filename (_GL_ATTRIBUTE_MAYBE_UNUSED html_styled_ostream_t stream) +html_styled_ostream_get_css_filename (html_styled_ostream_t _GL_UNNAMED (stream)) { return NULL; } static inline html_styled_ostream_t -html_styled_ostream_create (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t destination, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *css_filename) +html_styled_ostream_create (ostream_t _GL_UNNAMED (destination), + const char *_GL_UNNAMED (css_filename)) { /* Not supported without the real libtextstyle. */ abort (); @@ -641,7 +638,7 @@ html_styled_ostream_create (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t destination, } static inline bool -is_instance_of_html_styled_ostream (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t stream) +is_instance_of_html_styled_ostream (ostream_t _GL_UNNAMED (stream)) { return false; } @@ -667,7 +664,7 @@ noop_styled_ostream_get_destination (noop_styled_ostream_t stream) } static inline bool -noop_styled_ostream_is_owning_destination (_GL_ATTRIBUTE_MAYBE_UNUSED noop_styled_ostream_t stream) +noop_styled_ostream_is_owning_destination (noop_styled_ostream_t _GL_UNNAMED (stream)) { return true; } @@ -682,7 +679,7 @@ noop_styled_ostream_create (ostream_t destination, bool pass_ownership) } static inline bool -is_instance_of_noop_styled_ostream (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t stream) +is_instance_of_noop_styled_ostream (ostream_t _GL_UNNAMED (stream)) { return false; } @@ -697,13 +694,13 @@ enum color_option { color_no, color_tty, color_yes, color_html }; #define style_file_name NULL static inline bool -handle_color_option (_GL_ATTRIBUTE_MAYBE_UNUSED const char *option) +handle_color_option (const char *_GL_UNNAMED (option)) { return false; } static inline void -handle_style_option (_GL_ATTRIBUTE_MAYBE_UNUSED const char *option) +handle_style_option (const char *_GL_UNNAMED (option)) { } @@ -715,10 +712,10 @@ print_color_test (void) } static inline void -style_file_prepare (_GL_ATTRIBUTE_MAYBE_UNUSED const char *style_file_envvar, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *stylesdir_envvar, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *stylesdir_after_install, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *default_style_file) +style_file_prepare (const char *_GL_UNNAMED (style_file_envvar), + const char *_GL_UNNAMED (stylesdir_envvar), + const char *_GL_UNNAMED (stylesdir_after_install), + const char *_GL_UNNAMED (default_style_file)) { } @@ -726,14 +723,14 @@ style_file_prepare (_GL_ATTRIBUTE_MAYBE_UNUSED const char *style_file_envvar, static inline styled_ostream_t styled_ostream_create (int fd, const char *filename, - _GL_ATTRIBUTE_MAYBE_UNUSED ttyctl_t tty_control, - _GL_ATTRIBUTE_MAYBE_UNUSED const char *css_filename) + ttyctl_t _GL_UNNAMED (tty_control), + const char *_GL_UNNAMED (css_filename)) { return fd_ostream_create (fd, filename, true); } static inline void -libtextstyle_set_failure_exit_code (_GL_ATTRIBUTE_MAYBE_UNUSED int exit_code) +libtextstyle_set_failure_exit_code (int _GL_UNNAMED (exit_code)) { } diff --git a/lib/unistr.in.h b/lib/unistr.in.h index 4b80b1610d..5f23562cb4 100644 --- a/lib/unistr.in.h +++ b/lib/unistr.in.h @@ -267,7 +267,7 @@ extern int # else static inline int u32_mbtouc_unsafe (ucs4_t *puc, - const uint32_t *s, _GL_ATTRIBUTE_MAYBE_UNUSED size_t n) + const uint32_t *s, size_t _GL_UNNAMED (n)) { uint32_t c = *s; @@ -334,7 +334,7 @@ extern int # else static inline int u32_mbtouc (ucs4_t *puc, const uint32_t *s, - _GL_ATTRIBUTE_MAYBE_UNUSED size_t n) + size_t _GL_UNNAMED (n)) { uint32_t c = *s; diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 9cdb21ac26..efd9f23126 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -593,7 +593,9 @@ AC_DEFUN([gl_COMMON_BODY], [ /* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if the entity is not used. The compiler should not warn if the entity is not - used. */ + used. However, 'int _GL_UNNAMED (i)' is preferable to + '_GL_ATTRIBUTE_MAYBE_UNUSED int i' when parameter I is unused + regardless of preprocessor macro settings. */ /* Applies to: - function, variable, - struct, union, struct/union member, @@ -879,6 +881,21 @@ AC_DEFUN([gl_COMMON_BODY], [ # endif #endif +/* _GL_UNNAMED (ID) is the "name" of an unnamed function parameter. + Each of the function's unnamed parameters should have a unique "name". + The "name" cannot be used. This ports both to C17 and earlier, which + lack unnamed parameters, and to C++ and later C, which have them. */ +/* Applies to: + - function parameters. */ +#ifndef _GL_UNNAMED +# if ((defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 202311 \ + && !defined __cplusplus) +# define _GL_UNNAMED(id) unnamed_##id _GL_ATTRIBUTE_UNUSED +# else +# define _GL_UNNAMED(id) +# endif +#endif + /* The following attributes enable detection of multithread-safety problems and resource leaks at compile-time, by clang ≥ 15, when the warning option -Wthread-safety is enabled. For usage, see diff --git a/tests/test-hamt.c b/tests/test-hamt.c index b72ae62b8d..7e0f311485 100644 --- a/tests/test-hamt.c +++ b/tests/test-hamt.c @@ -163,8 +163,7 @@ test_general (void) } static bool -true_processor (_GL_ATTRIBUTE_MAYBE_UNUSED Hamt_entry *elt, - _GL_ATTRIBUTE_MAYBE_UNUSED void *data) +true_processor (Hamt_entry *_GL_UNNAMED (elt), void *_GL_UNNAMED (data)) { return true; } -- 2.51.0
