diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 3a6bc79d0..15b102068 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -3158,6 +3158,9 @@ Check::FileInfo *CheckClass::getFileInfo(const Tokenizer *tokenizer, const Setti if (classScope->isAnonymous()) continue; + if (classScope->classDef && Token::simpleMatch(classScope->classDef->previous(), ">")) + continue; + // the full definition must be compared const bool fullDefinition = std::all_of(classScope->functionList.cbegin(), classScope->functionList.cend(), diff --git a/test/testclass.cpp b/test/testclass.cpp index 93d85a623..c9ddee6b2 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -8546,6 +8546,12 @@ private: ctu({"class A::C { C() { std::cout << 0; } };", "class B::C { C() { std::cout << 1; } };"}); ASSERT_EQUALS("", errout.str()); + + // 11435 - template specialisations + const std::string header = "template struct Test {};\n"; + ctu({header + "template struct Test {};\n", + header + "template struct Test {};\n"}); + ASSERT_EQUALS("", errout.str()); }