improve noConstructor message (#3750)
This commit is contained in:
parent
8f7770f512
commit
4127885282
|
@ -967,8 +967,8 @@ void CheckClass::noConstructorError(const Token *tok, const std::string &classna
|
|||
// For performance reasons the constructor might be intentionally missing. Therefore this is not a "warning"
|
||||
reportError(tok, Severity::style, "noConstructor",
|
||||
"$symbol:" + classname + "\n" +
|
||||
"The " + std::string(isStruct ? "struct" : "class") + " '$symbol' does not have a constructor although it has private member variables.\n"
|
||||
"The " + std::string(isStruct ? "struct" : "class") + " '$symbol' does not have a constructor "
|
||||
"The " + std::string(isStruct ? "struct" : "class") + " '$symbol' does not declare a constructor although it has private member variables which likely require initialization.\n"
|
||||
"The " + std::string(isStruct ? "struct" : "class") + " '$symbol' does not declare a constructor "
|
||||
"although it has private member variables. Member variables of builtin types are left "
|
||||
"uninitialized when the class is instantiated. That may cause bugs or undefined behavior.", CWE398, Certainty::normal);
|
||||
}
|
||||
|
|
|
@ -242,14 +242,14 @@ private:
|
|||
"private:\n"
|
||||
" int i;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not have a constructor although it has private member variables.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not declare a constructor although it has private member variables which likely require initialization.\n", errout.str());
|
||||
|
||||
check("struct Fred\n"
|
||||
"{\n"
|
||||
"private:\n"
|
||||
" int i;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:1]: (style) The struct 'Fred' does not have a constructor although it has private member variables.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:1]: (style) The struct 'Fred' does not declare a constructor although it has private member variables which likely require initialization.\n", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -403,8 +403,8 @@ private:
|
|||
check("struct Fred { int x; };\n"
|
||||
"class Barney { Fred fred; };\n"
|
||||
"class Wilma { struct Betty { int x; } betty; };");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) The class 'Barney' does not have a constructor although it has private member variables.\n"
|
||||
"[test.cpp:3]: (style) The class 'Wilma' does not have a constructor although it has private member variables.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) The class 'Barney' does not declare a constructor although it has private member variables which likely require initialization.\n"
|
||||
"[test.cpp:3]: (style) The class 'Wilma' does not declare a constructor although it has private member variables which likely require initialization.\n", errout.str());
|
||||
}
|
||||
|
||||
void simple9() { // ticket #4574
|
||||
|
@ -521,7 +521,7 @@ private:
|
|||
"{\n"
|
||||
" int i;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not have a constructor although it has private member variables.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not declare a constructor although it has private member variables which likely require initialization.\n", errout.str());
|
||||
}
|
||||
|
||||
void noConstructor2() {
|
||||
|
|
Loading…
Reference in New Issue