fix false positive of virtual function call (#3553)
This commit is contained in:
parent
77069d810c
commit
5865b05703
|
@ -2423,7 +2423,7 @@ void CheckClass::checkVirtualFunctionCallInConstructor()
|
||||||
continue;
|
continue;
|
||||||
if (callstack.back()->function()->isPure())
|
if (callstack.back()->function()->isPure())
|
||||||
pureVirtualFunctionCallInConstructorError(scope->function, callstack, callstack.back()->str());
|
pureVirtualFunctionCallInConstructorError(scope->function, callstack, callstack.back()->str());
|
||||||
else
|
else if (!callstack.back()->function()->hasFinalSpecifier())
|
||||||
virtualFunctionCallInConstructorError(scope->function, callstack, callstack.back()->str());
|
virtualFunctionCallInConstructorError(scope->function, callstack, callstack.back()->str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6968,6 +6968,17 @@ private:
|
||||||
" A() { f(); }\n"
|
" A() { f(); }\n"
|
||||||
"};\n");
|
"};\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkVirtualFunctionCall("class B {\n"
|
||||||
|
"public:"
|
||||||
|
" virtual void f() {}\n"
|
||||||
|
"};\n"
|
||||||
|
"class A : B {\n"
|
||||||
|
"public:"
|
||||||
|
" void f() override final {}\n"
|
||||||
|
" A() { f(); }\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void pureVirtualFunctionCall() {
|
void pureVirtualFunctionCall() {
|
||||||
|
|
Loading…
Reference in New Issue