m4: fix gnulib nodiscard declarations for GCC 15

GCC 15 defaults to C23, which requires nodiscard to precede
the declaration specifiers. The gnulib copy in M4 1.4.19 puts
it after the inline specifier and the compiler rejects it.

Backport the list and ordered-set header changes from gnulib
786bb6fb17d6 to preserve the warning attribute in C23.

Link: https://github.com/coreutils/gnulib/commit/786bb6fb17d698eb175942606db8fb129e231474
Assisted-by: LLM
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Hauke Mehrtens authored and Hannu Nyman committed 2026-12-05 18:54:51 +02:00
1 parent c9a9737088
commit 7d55d7a87c
2 files changed
+237 -1

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=m4
PKG_VERSION:=1.4.19
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE_URL:=@GNU/m4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
@@ -0,0 +1,236 @@
From 786bb6fb17d698eb175942606db8fb129e231474 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 30 Jul 2021 12:56:24 -0700
Subject: [PATCH] gnulib-common: update for C2x 2020-12-11 draft
Backport the gnulib list and ordered-set header changes. Keep the C23
nodiscard attribute on the affected declarations.
Upstream-Status: Backport [https://github.com/coreutils/gnulib/commit/786bb6fb17d698eb175942606db8fb129e231474]
--- a/lib/gl_list.h
+++ b/lib/gl_list.h
@@ -197,9 +197,9 @@ extern const void * gl_list_node_value (
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
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
/* 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_fir
/* 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 (g
/* 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_las
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_bef
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_aft
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_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_l
->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,
->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
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
--- a/lib/gl_oset.h
+++ b/lib/gl_oset.h
@@ -134,9 +134,10 @@ extern bool gl_oset_search_atleast (gl_o
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);