]> Savannah Git Hosting - gnulib.git/commitdiff
stack: Silence gcc warning in tests.
authorBruno Haible <bruno@clisp.org>
Thu, 18 May 2023 20:48:54 +0000 (22:48 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 18 May 2023 20:54:46 +0000 (22:54 +0200)
* lib/stack.h (init, destroy, empty, current_base, push, pop, discard,
top, size): Mark as possibly unused.

ChangeLog
lib/stack.h

index aff37369efbb01043c6918bb09fc88d6b4c43210..0216321fc6dbee51efd1a4382aeb7acb7ad0b0a0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-05-18  Bruno Haible  <bruno@clisp.org>
+
+       stack: Silence gcc warning in tests.
+       * lib/stack.h (init, destroy, empty, current_base, push, pop, discard,
+       top, size): Mark as possibly unused.
+
 2023-05-18  Bruno Haible  <bruno@clisp.org>
 
        hamt: Silence gcc warning.
index ab6b87317629fb151f51bc39b8ebc5e105b46d5c..dbd6812bc800a7b54bfd9fb2eb2fa50a37c25059 100644 (file)
@@ -58,7 +58,7 @@
      #include "xalloc.h"
 */
 
-/* This file uses _GL_ATTRIBUTE_PURE.  */
+/* This file uses _GL_ATTRIBUTE_MAYBE_UNUSED, _GL_ATTRIBUTE_PURE.  */
 #if !_GL_CONFIG_H_INCLUDED
  #error "Please include config.h first."
 #endif
@@ -86,6 +86,7 @@ typedef struct
 } _GL_STACK_TYPE;
 
 /* Initialize a stack.  */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 GL_STACK_STORAGECLASS void
 _GL_STACK_PREFIX (init) (_GL_STACK_TYPE *stack)
 {
@@ -95,6 +96,7 @@ _GL_STACK_PREFIX (init) (_GL_STACK_TYPE *stack)
 }
 
 /* Destroy a stack by freeing the allocated space.  */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 GL_STACK_STORAGECLASS void
 _GL_STACK_PREFIX (destroy) (_GL_STACK_TYPE *stack)
 {
@@ -102,7 +104,8 @@ _GL_STACK_PREFIX (destroy) (_GL_STACK_TYPE *stack)
 }
 
 /* Return true if the stack currently holds no element.  */
-GL_STACK_STORAGECLASS _GL_ATTRIBUTE_PURE bool
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_PURE
+GL_STACK_STORAGECLASS bool
 _GL_STACK_PREFIX (empty) (const _GL_STACK_TYPE *stack)
 {
   return stack->size == 0;
@@ -112,13 +115,15 @@ _GL_STACK_PREFIX (empty) (const _GL_STACK_TYPE *stack)
 
    The result is invalidated as soon as an element is added or removed
    from the stack.  */
-GL_STACK_STORAGECLASS _GL_ATTRIBUTE_PURE GL_STACK_ELEMENT *
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_PURE
+GL_STACK_STORAGECLASS GL_STACK_ELEMENT *
 _GL_STACK_PREFIX (current_base) (const _GL_STACK_TYPE *stack)
 {
   return stack->base;
 }
 
 /* Push an element to the top of the stack.  */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 GL_STACK_STORAGECLASS void
 _GL_STACK_PREFIX (push) (_GL_STACK_TYPE *stack, GL_STACK_ELEMENT item)
 {
@@ -130,6 +135,7 @@ _GL_STACK_PREFIX (push) (_GL_STACK_TYPE *stack, GL_STACK_ELEMENT item)
 
 /* Pop the element from the top of the stack, which must be non-empty,
    and return it. */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 GL_STACK_STORAGECLASS GL_STACK_ELEMENT
 _GL_STACK_PREFIX (pop) (_GL_STACK_TYPE *stack)
 {
@@ -139,6 +145,7 @@ _GL_STACK_PREFIX (pop) (_GL_STACK_TYPE *stack)
 
 /* Pop the element from the top of the stack, which must be
    non-empty.  */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 GL_STACK_STORAGECLASS void
 _GL_STACK_PREFIX (discard) (_GL_STACK_TYPE *stack)
 {
@@ -148,6 +155,7 @@ _GL_STACK_PREFIX (discard) (_GL_STACK_TYPE *stack)
 
 /* Return the element from the top of the stack, which must be
    non-empty.  */
+_GL_ATTRIBUTE_MAYBE_UNUSED
 GL_STACK_STORAGECLASS GL_STACK_ELEMENT
 _GL_STACK_PREFIX (top) (const _GL_STACK_TYPE *stack)
 {
@@ -156,7 +164,8 @@ _GL_STACK_PREFIX (top) (const _GL_STACK_TYPE *stack)
 }
 
 /* Return the currently stored number of elements in the stack.  */
-GL_STACK_STORAGECLASS _GL_ATTRIBUTE_PURE idx_t
+_GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_PURE
+GL_STACK_STORAGECLASS idx_t
 _GL_STACK_PREFIX (size) (const _GL_STACK_TYPE *stack)
 {
   return stack->size;