]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
argp: Use the counted_by attribute.
authorBruno Haible <bruno@clisp.org>
Sun, 3 May 2026 06:51:08 +0000 (08:51 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 3 May 2026 13:34:21 +0000 (15:34 +0200)
* lib/argp-help.c (struct hol): Mark the entries fields as counted_by
num_entries. Swap these fields (needed for clang, see
<https://discourse.llvm.org/t/rfc-forward-referencing-a-struct-member-within-bounds-annotations/85510>).

ChangeLog
lib/argp-help.c

index af44055e31e73f7591c86b1dc2a63641210902c2..84bc54f29992640e65a373039fc465d0515a01cf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-05-03  Bruno Haible  <bruno@clisp.org>
+
+       argp: Use the counted_by attribute.
+       * lib/argp-help.c (struct hol): Mark the entries fields as counted_by
+       num_entries. Swap these fields (needed for clang, see
+       <https://discourse.llvm.org/t/rfc-forward-referencing-a-struct-member-within-bounds-annotations/85510>).
+
 2026-05-03  Bruno Haible  <bruno@clisp.org>
 
        dfa: Remove a redundant forward declaration.
index 8a3e72e79cbb0fc1ebc7f11d2a0ebfa490bfc2c9..d9253367751b684c1f77a249d74ce5adb70b3e8e 100644 (file)
@@ -419,11 +419,12 @@ struct hol_cluster
 /* A list of options for help.  */
 struct hol
 {
-  /* An array of hol_entry's.  */
-  struct hol_entry *entries;
   /* The number of entries in this hol.  If this field is zero, entries and
      short_options are undefined.  */
   unsigned num_entries;
+  /* An array of hol_entry's.  */
+  struct hol_entry *entries
+    _GL_ATTRIBUTE_COUNTED_BY (num_entries);
 
   /* A string containing all short options in this HOL.  Each entry contains
      pointers into this string, so the order can't be messed with blindly.  */