Fixed #8523 (Clarify warning: noConstructor)
This commit is contained in:
parent
40b6f6b3dd
commit
31148fdfed
|
@ -872,7 +872,7 @@ 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"
|
// For performance reasons the constructor might be intentionally missing. Therefore this is not a "warning"
|
||||||
reportError(tok, Severity::style, "noConstructor",
|
reportError(tok, Severity::style, "noConstructor",
|
||||||
"$symbol:" + classname + "\n" +
|
"$symbol:" + classname + "\n" +
|
||||||
"The " + std::string(isStruct ? "struct" : "class") + " '$symbol' does not have a constructor.\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 have a constructor "
|
||||||
"although it has private member variables. Member variables of builtin types are left "
|
"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, false);
|
"uninitialized when the class is instantiated. That may cause bugs or undefined behavior.", CWE398, false);
|
||||||
|
|
|
@ -208,14 +208,14 @@ private:
|
||||||
"private:\n"
|
"private:\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not have a constructor.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not have a constructor although it has private member variables.\n", errout.str());
|
||||||
|
|
||||||
check("struct Fred\n"
|
check("struct Fred\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"private:\n"
|
"private:\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (style) The struct 'Fred' does not have a constructor.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (style) The struct 'Fred' does not have a constructor although it has private member variables.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -369,8 +369,8 @@ private:
|
||||||
check("struct Fred { int x; };\n"
|
check("struct Fred { int x; };\n"
|
||||||
"class Barney { Fred fred; };\n"
|
"class Barney { Fred fred; };\n"
|
||||||
"class Wilma { struct Betty { int x; } betty; };");
|
"class Wilma { struct Betty { int x; } betty; };");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (style) The class 'Barney' does not have a constructor.\n"
|
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.\n", errout.str());
|
"[test.cpp:3]: (style) The class 'Wilma' does not have a constructor although it has private member variables.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void simple9() { // ticket #4574
|
void simple9() { // ticket #4574
|
||||||
|
@ -470,7 +470,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
"};");
|
"};");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not have a constructor.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (style) The class 'Fred' does not have a constructor although it has private member variables.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void noConstructor2() {
|
void noConstructor2() {
|
||||||
|
|
Loading…
Reference in New Issue