+2025-05-10 Bruno Haible <bruno@clisp.org>
+
+ string-desc, xstring-desc: Avoid GCC attributes in function definitions.
+ Reported by Collin Funk in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2025-05/msg00126.html>.
+ * lib/attribute.h: Clarify the allowed positions of attributes in
+ function definitions.
+ * lib/string-desc.h (_sd_char_at): Add a declaration, to hold the
+ gcc attrribute.
+ * lib/xstring-desc.h (_xsd_c): Likewise.
+
2025-05-10 Bruno Haible <bruno@clisp.org>
string-desc: Improve a declaration.
- In a function declaration/definition with a storage-class
specifier: between the storage-class specifier and the return
type.
- - Or after the parameter list,
- ∙ but after ATTRIBUTE_NOTHROW if present.
+ - Or, in a function declaration:
+ after the parameter list,
+ ∙ but after ATTRIBUTE_NOTHROW if present.
In other declarations, such as variable declarations:
})
GL_STRING_DESC_INLINE char
_sd_char_at (idx_t s_nbytes, const char *s_data, idx_t i)
- _GL_ATTRIBUTE_NONNULL ((2))
+ _GL_ATTRIBUTE_NONNULL ((2));
+GL_STRING_DESC_INLINE char
+_sd_char_at (idx_t s_nbytes, const char *s_data, idx_t i)
{
if (!(i >= 0 && i < s_nbytes))
/* Invalid argument. */
_GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_RETURNS_NONNULL
char *
_xsd_c (idx_t s_nbytes, const char *s_data)
- _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 1)
+ _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 1);
+GL_XSTRING_DESC_INLINE
+_GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_RETURNS_NONNULL
+char *
+_xsd_c (idx_t s_nbytes, const char *s_data)
{
char *result = _sd_c (s_nbytes, s_data);
if (result == NULL)