Fixed #4574 (noConstructor false positives introduced in cppcheck 1.58)

This commit is contained in:
Robert Reif 2013-02-13 06:00:04 +01:00 committed by Daniel Marjamki
parent 213d31b360
commit 5de26bfeb9
2 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -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"