missingOverride: False positive with cv-ref mismatch (#1340)
This commit is contained in:
parent
0e70c8a916
commit
13617375df
|
@ -3203,7 +3203,17 @@ const Function * Function::getOverridenFunctionRecursive(const ::Type* baseType,
|
|||
}
|
||||
|
||||
// check for matching function parameters
|
||||
if (match && argsMatch(baseType->classScope, func->argDef, argDef, emptyString, 0)) {
|
||||
match = match && argsMatch(baseType->classScope, func->argDef, argDef, emptyString, 0);
|
||||
|
||||
// check for matching cv-ref qualifiers
|
||||
match = match
|
||||
&& isConst() == func->isConst()
|
||||
&& isVolatile() == func->isVolatile()
|
||||
&& hasRvalRefQualifier() == func->hasRvalRefQualifier()
|
||||
&& hasLvalRefQualifier() == func->hasLvalRefQualifier();
|
||||
|
||||
// it's a match
|
||||
if (match) {
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,6 +214,7 @@ private:
|
|||
TEST_CASE(unsafeClassDivZero);
|
||||
|
||||
TEST_CASE(override1);
|
||||
TEST_CASE(overrideCVRefQualifiers);
|
||||
}
|
||||
|
||||
void checkCopyCtorAndEqOperator(const char code[]) {
|
||||
|
@ -6827,6 +6828,24 @@ private:
|
|||
"class Derived : Base { virtual void f() final; };");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void overrideCVRefQualifiers() {
|
||||
checkOverride("class Base { virtual void f(); };\n"
|
||||
"class Derived : Base { void f() const; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkOverride("class Base { virtual void f(); };\n"
|
||||
"class Derived : Base { void f() volatile; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkOverride("class Base { virtual void f(); };\n"
|
||||
"class Derived : Base { void f() &; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkOverride("class Base { virtual void f(); };\n"
|
||||
"class Derived : Base { void f() &&; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestClass)
|
||||
|
|
Loading…
Reference in New Issue