From 1a8c2233355e2c6e524c13b845fd50828d3a1117 Mon Sep 17 00:00:00 2001 From: firewave Date: Mon, 2 Feb 2026 13:16:00 +0100 Subject: [PATCH] refs #14226 - PathMatch: removed need for test class friend declaration --- lib/pathmatch.h | 4 ++-- test/testpathmatch.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/pathmatch.h b/lib/pathmatch.h index b89ddcbe40b..ab9d2a3c43d 100644 --- a/lib/pathmatch.h +++ b/lib/pathmatch.h @@ -169,10 +169,10 @@ class CPPCHECKLIB PathMatch { return pattern; } -private: - friend class TestPathMatch; +protected: class PathIterator; +private: /* List of patterns */ std::vector mPatterns; /* Base path to with patterns and paths are relative */ diff --git a/test/testpathmatch.cpp b/test/testpathmatch.cpp index 2be6a943845..dc55bacf339 100644 --- a/test/testpathmatch.cpp +++ b/test/testpathmatch.cpp @@ -28,6 +28,11 @@ class TestPathMatch : public TestFixture { TestPathMatch() : TestFixture("TestPathMatch") {} private: + class PathMatchTest final : public PathMatch + { + friend class TestPathMatch; + }; + static constexpr auto unix = PathMatch::Syntax::unix; static constexpr auto windows = PathMatch::Syntax::windows; static constexpr auto ifreg = PathMatch::Filemode::regular; @@ -277,7 +282,7 @@ class TestPathMatch : public TestFixture { void pathiterator() const { /* See https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats * for information on Windows path syntax. */ - using PathIterator = PathMatch::PathIterator; + using PathIterator = PathMatchTest::PathIterator; ASSERT_EQUALS("/", PathIterator("/", nullptr, unix).read()); ASSERT_EQUALS("/", PathIterator("//", nullptr, unix).read()); ASSERT_EQUALS("/", PathIterator("/", "/", unix).read());