Fixed #4574 (noConstructor false positives introduced in cppcheck 1.58)
This commit is contained in:
parent
213d31b360
commit
5de26bfeb9
|
@ -1975,7 +1975,11 @@ Scope::Scope(SymbolDatabase *check_, const Token *classDef_, Scope *nestedIn_) :
|
|||
type = Scope::eGlobal;
|
||||
} else if (classDef->str() == "class") {
|
||||
type = Scope::eClass;
|
||||
className = classDef->next()->str();
|
||||
// skip over qualification if present
|
||||
const Token *nameTok = classDef->next();
|
||||
while (nameTok && Token::Match(nameTok, "%type% ::"))
|
||||
nameTok = nameTok->tokAt(2);
|
||||
className = nameTok->str();
|
||||
} else if (classDef->str() == "struct") {
|
||||
type = Scope::eStruct;
|
||||
// anonymous and unnamed structs don't have a name
|
||||
|
|
|
@ -61,6 +61,7 @@ private:
|
|||
TEST_CASE(simple6); // ticket #4085 - uninstantiated template class
|
||||
TEST_CASE(simple7); // ticket #4531
|
||||
TEST_CASE(simple8);
|
||||
TEST_CASE(simple9); // ticket #4574
|
||||
|
||||
TEST_CASE(initvar_with_this); // BUG 2190300
|
||||
TEST_CASE(initvar_if); // BUG 2190290
|
||||
|
@ -320,6 +321,16 @@ private:
|
|||
"[test.cpp:3]: (style) The class 'Wilma' does not have a constructor.\n", errout.str());
|
||||
}
|
||||
|
||||
void simple9() { // ticket #4574
|
||||
check("class Unknown::Fred {\n"
|
||||
"public:\n"
|
||||
" Fred() : x(0) { }\n"
|
||||
"private:\n"
|
||||
" int x;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void initvar_with_this() {
|
||||
check("struct Fred\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue