diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 398b844db..9e647f381 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2440,7 +2440,7 @@ void CheckClass::virtualFunctionCallInConstructorError( } } - reportError(errorPath, Severity::warning, "virtualCallInConstructor", + reportError(errorPath, Severity::style, "virtualCallInConstructor", "Virtual function '" + funcname + "' is called from " + scopeFunctionTypeName + " '" + constructorName + "' at line " + MathLib::toString(lineNumber) + ". Dynamic binding is not used.", CWE(0U), false); } diff --git a/lib/checkclass.h b/lib/checkclass.h index 4477d3be7..b754550ee 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -73,7 +73,8 @@ public: checkClass.virtualDestructor(); checkClass.checkConst(); checkClass.copyconstructors(); - checkClass.checkVirtualFunctionCallInConstructor(); + // FIXME: Only report warnings for inherited classes + // checkClass.checkVirtualFunctionCallInConstructor(); checkClass.checkDuplInheritedMembers(); checkClass.checkExplicitConstructors(); checkClass.checkCopyCtorAndEqOperator(); diff --git a/test/testclass.cpp b/test/testclass.cpp index 2ab038125..684088790 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -6836,21 +6836,21 @@ private: "};\n" "A::A()\n" "{f();}\n"); - 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()); + ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (style) Virtual function 'f' is called from constructor 'A()' at line 7. Dynamic binding is not used.\n", errout.str()); checkVirtualFunctionCall("class A {\n" " virtual int f();\n" " A() {f();}\n" "};\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. Dynamic binding is not used.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:2]: (style) Virtual function 'f' is called from constructor 'A()' at line 3. Dynamic binding is not used.\n", errout.str()); checkVirtualFunctionCall("class A : B {\n" " int f() override;\n" " A() {f();}\n" "};\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. Dynamic binding is not used.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:2]: (style) Virtual function 'f' is called from constructor 'A()' at line 3. Dynamic binding is not used.\n", errout.str()); checkVirtualFunctionCall("class B {\n" " virtual int f() = 0;\n" @@ -6860,7 +6860,7 @@ private: " A() {f();}\n" "};\n" "int A::f() { return 1; }\n"); - ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:5]: (warning) Virtual function 'f' is called from constructor 'A()' at line 6. Dynamic binding is not used.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:5]: (style) Virtual function 'f' is called from constructor 'A()' at line 6. Dynamic binding is not used.\n", errout.str()); checkVirtualFunctionCall("class A\n" "{\n"