]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
string-desc, xstring-desc: Avoid GCC attributes in function definitions.
authorBruno Haible <bruno@clisp.org>
Sat, 10 May 2025 15:12:28 +0000 (17:12 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 10 May 2025 15:12:28 +0000 (17:12 +0200)
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.

ChangeLog
lib/attribute.h
lib/string-desc.h
lib/xstring-desc.h

index c71bacdda9b8d95c9019a60a4a686e7a500d6fec..2d7696a717789c2617c66c3e008c51bc39daa199 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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.
index ae7bbe8e2cb939866e17c9c922e0bc7d17664d9c..c85412d90af21a999b6d5790a8fb30821ae8c2fd 100644 (file)
@@ -50,8 +50,9 @@
              - 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:
 
index 8bd6691914a313b4ef5dffec77bdd9b371e3ad11..db6925d0d80702e2fc60f2d2c9533ccfb19e0325 100644 (file)
@@ -319,7 +319,9 @@ sd_length (string_desc_t s)
    })
 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.  */
index 216865a267d09769e785db8d74f32ffdbcc41362..17ea35e357ef89c078c9fe7dbaffe579fb3195ab 100644 (file)
@@ -100,7 +100,11 @@ GL_XSTRING_DESC_INLINE
 _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)