Fix #11435 (FP ctuOneDefinitionRuleViolation for template specialization) (#5156)

This commit is contained in:
Daniel Marjamäki 2023-06-15 11:43:07 +02:00 committed by GitHub
parent c033c62190
commit d75331d00d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -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(),

View File

@ -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<typename T1, typename T2> struct Test {};\n";
ctu({header + "template<typename T1> struct Test<T1, int> {};\n",
header + "template<typename T1> struct Test<T1, double> {};\n"});
ASSERT_EQUALS("", errout.str());
}