From da95d1184e8274f37820fbec6750ee69f336161d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 10 Jul 2026 23:25:21 +0200 Subject: [PATCH] Fix -Wunneeded-internal-declaration for CustomSentinel in test CustomSentinel lives in an anonymous namespace (internal linkage), and the library's parse loop only ever evaluates the iterator-first direction (it != last), so the reversed-order friend operator!= was never referenced. Clang's -Weverything flags such unused internal declarations as an error. Drop the unused overload; the used direction is enough to satisfy can_compare_ne's either-order detection. Signed-off-by: Niels Lohmann --- tests/src/unit-user_defined_input.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/src/unit-user_defined_input.cpp b/tests/src/unit-user_defined_input.cpp index 7c6d5b746..0884b193d 100644 --- a/tests/src/unit-user_defined_input.cpp +++ b/tests/src/unit-user_defined_input.cpp @@ -173,16 +173,13 @@ struct CustomSentinel { const char* end_ptr; - // Support both directions for != comparison + // only the iterator-first direction (it != sentinel) is ever evaluated by + // the library's parse loop; a reversed-order overload would go unused and + // trip -Wunneeded-internal-declaration under -Weverything friend bool operator!=(const char* it, const CustomSentinel& sentinel) { return it != sentinel.end_ptr; } - - friend bool operator!=(const CustomSentinel& sentinel, const char* it) - { - return it != sentinel.end_ptr; - } }; TEST_CASE("Parse with heterogeneous iterator and sentinel types")