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());