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;
|
||||
if (callstack.back()->function()->isPure())
|
||||
pureVirtualFunctionCallInConstructorError(scope->function, callstack, callstack.back()->str());
|
||||
else
|
||||
else if (!callstack.back()->function()->hasFinalSpecifier())
|
||||
virtualFunctionCallInConstructorError(scope->function, callstack, callstack.back()->str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6968,6 +6968,17 @@ private:
|
|||
" A() { f(); }\n"
|
||||
"};\n");
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue