Symbol database: handle when forward declaration doesn't match declaration. Ticket: #4531

This commit is contained in:
Robert Reif 2013-02-01 06:31:02 +01:00 committed by Daniel Marjamäki
parent 94c953931d
commit 1a58ae4994
2 changed files with 19 additions and 0 deletions

View File

@ -88,6 +88,16 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
break;
}
}
// definition may be different than declaration
if (tok->str() == "class") {
access[new_scope] = Private;
new_scope->type = Scope::eClass;
} else if (tok->str() == "struct") {
access[new_scope] = Public;
new_scope->type = Scope::eStruct;
}
back[tok2->link()] = scope;
new_scope->classDef = tok;
new_scope->classStart = tok2;

View File

@ -59,6 +59,7 @@ private:
TEST_CASE(simple4);
TEST_CASE(simple5); // ticket #2560
TEST_CASE(simple6); // ticket #4085 - uninstantiated template class
TEST_CASE(simple7); // ticket #4531
TEST_CASE(initvar_with_this); // BUG 2190300
TEST_CASE(initvar_if); // BUG 2190290
@ -302,6 +303,14 @@ private:
"[test.cpp:3]: (warning) Member variable 'A::y' is not initialized in the constructor.\n", errout.str());
}
void simple7() { // ticket #4531
check("class Fred;\n"
"struct Fred {\n"
" int x;\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void initvar_with_this() {
check("struct Fred\n"
"{\n"