Fixed #8636 (Misleading verbose message if virtual method called from destructor)
This commit is contained in:
parent
fc5d8e5082
commit
54e2726bf3
|
@ -2377,8 +2377,7 @@ void CheckClass::virtualFunctionCallInConstructorError(
|
||||||
}
|
}
|
||||||
|
|
||||||
reportError(errorPath, Severity::warning, "virtualCallInConstructor",
|
reportError(errorPath, Severity::warning, "virtualCallInConstructor",
|
||||||
"Virtual function '" + funcname + "' is called from " + scopeFunctionTypeName + " '" + constructorName + "' at line " + MathLib::toString(lineNumber) + ".\n"
|
"Virtual function '" + funcname + "' is called from " + scopeFunctionTypeName + " '" + constructorName + "' at line " + MathLib::toString(lineNumber) + ". Dynamic binding is not used.", CWE(0U), false);
|
||||||
"Call of pure virtual function '" + funcname + "' in " + scopeFunctionTypeName + ". Dynamic binding is not used.", CWE(0U), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckClass::pureVirtualFunctionCallInConstructorError(
|
void CheckClass::pureVirtualFunctionCallInConstructorError(
|
||||||
|
|
|
@ -6533,14 +6533,14 @@ private:
|
||||||
"};\n"
|
"};\n"
|
||||||
"A::A()\n"
|
"A::A()\n"
|
||||||
"{f();}\n");
|
"{f();}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (warning) Virtual function 'f' is called from constructor 'A()' at line 7.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (warning) Virtual function 'f' is called from constructor 'A()' at line 7. Dynamic binding is not used.\n", errout.str());
|
||||||
|
|
||||||
checkVirtualFunctionCall("class A {\n"
|
checkVirtualFunctionCall("class A {\n"
|
||||||
" virtual int f();\n"
|
" virtual int f();\n"
|
||||||
" A() {f();}\n"
|
" A() {f();}\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"int A::f() { return 1; }\n");
|
"int A::f() { return 1; }\n");
|
||||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:2]: (warning) Virtual function 'f' is called from constructor 'A()' at line 3.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:2]: (warning) Virtual function 'f' is called from constructor 'A()' at line 3. Dynamic binding is not used.\n", errout.str());
|
||||||
|
|
||||||
checkVirtualFunctionCall("class A\n"
|
checkVirtualFunctionCall("class A\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue