diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index e27a858a8..33300f55f 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -836,7 +836,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti if (varId) _variableList[varId] = &(*var); // fix up variables without type - if (var->isClass() && !var->type()) { + if (!var->type() && !var->typeStartToken()->isStandardType()) { const Type *type = findType(var->typeStartToken(), scope); if (type) var->type(type); @@ -854,7 +854,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti if (declarationId > 0U) _variableList[declarationId] = &(*arg); // fix up parameters without type - if (arg->isClass() && !arg->type()) { + if (!arg->type() && !arg->typeStartToken()->isStandardType()) { const Type *type = findType(arg->typeStartToken(), scope); if (type) arg->type(type); diff --git a/test/testsuite.cpp b/test/testsuite.cpp index 1b6198482..86337cf7c 100644 --- a/test/testsuite.cpp +++ b/test/testsuite.cpp @@ -122,6 +122,20 @@ void TestFixture::assert_(const char *filename, unsigned int linenr, bool condit } } +void TestFixture::todoAssert(const char *filename, unsigned int linenr, bool condition) const +{ + if (condition) { + if (gcc_style_errors) { + errmsg << filename << ':' << linenr << ": Assertion succeeded unexpectedly." << std::endl; + } else { + errmsg << "Assertion succeeded unexpectedly in " << filename << " at line " << linenr << std::endl; + } + ++succeeded_todos_counter; + } else { + ++todos_counter; + } +} + void TestFixture::assertEquals(const char *filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg) const { if (expected != actual) { diff --git a/test/testsuite.h b/test/testsuite.h index 20adc7153..b6e44090d 100644 --- a/test/testsuite.h +++ b/test/testsuite.h @@ -46,6 +46,7 @@ protected: bool runTest(const char testname[]); void assert_(const char *filename, unsigned int linenr, bool condition) const; + void todoAssert(const char *filename, unsigned int linenr, bool condition) const; void assertEquals(const char *filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = "") const; void assertEquals(const char *filename, unsigned int linenr, long long expected, long long actual, const std::string &msg="") const; @@ -72,6 +73,7 @@ public: #define TEST_CASE( NAME ) if ( runTest(#NAME) ) { currentTest = classname + "::" + #NAME; if (quiet_tests) { REDIRECT; NAME(); } else { NAME ();} } #define ASSERT( CONDITION ) assert_(__FILE__, __LINE__, CONDITION) +#define TODO_ASSERT( CONDITION ) todoAssert(__FILE__, __LINE__, CONDITION) #define ASSERT_EQUALS( EXPECTED , ACTUAL ) assertEquals(__FILE__, __LINE__, EXPECTED, ACTUAL) #define ASSERT_EQUALS_DOUBLE( EXPECTED , ACTUAL ) assertEqualsDouble(__FILE__, __LINE__, EXPECTED, ACTUAL) #define ASSERT_EQUALS_MSG( EXPECTED , ACTUAL, MSG ) assertEquals(__FILE__, __LINE__, EXPECTED, ACTUAL, MSG) diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 4f4c7184c..f57ed708d 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -1586,29 +1586,34 @@ private: void symboldatabase37() { GET_SYMBOL_DB("class Fred {\n" "public:\n" + " struct Wilma { };\n" " struct Barney {\n" " bool operator == (const struct Barney & b) const { return true; }\n" + " bool operator == (const struct Wilma & w) const { return true; }\n" " };\n" " Fred(const struct Barney & b) { barney = b; }\n" "private:\n" " struct Barney barney;\n" "};\n"); - ASSERT(db && db->typeList.size() == 2); + ASSERT(db && db->typeList.size() == 3); ASSERT(db && db->isClassOrStruct("Fred")); + ASSERT(db && db->isClassOrStruct("Wilma")); ASSERT(db && db->isClassOrStruct("Barney")); - if (!db || db->typeList.size() == 2) + if (!db || db->typeList.size() != 3) return; std::list::const_iterator i = db->typeList.begin(); const Type* Fred = &(*i++); + const Type* Wilma = &(*i++); const Type* Barney = &(*i++); ASSERT(Fred && Fred->classDef && Fred->classScope && Fred->enclosingScope && Fred->name() == "Fred"); + ASSERT(Wilma && Wilma->classDef && Wilma->classScope && Wilma->enclosingScope && Wilma->name() == "Wilma"); ASSERT(Barney && Barney->classDef && Barney->classScope && Barney->enclosingScope && Barney->name() == "Barney"); - - ASSERT(db && db->getVariableListSize() == 4); - if (!db || db->getVariableListSize() == 4) + ASSERT(db && db->getVariableListSize() == 5); + if (!db || db->getVariableListSize() != 5) return; ASSERT(db && db->getVariableFromVarId(1) && db->getVariableFromVarId(1)->type() && db->getVariableFromVarId(1)->type()->name() == "Barney"); - ASSERT(db && db->getVariableFromVarId(2) && db->getVariableFromVarId(2)->type() && db->getVariableFromVarId(2)->type()->name() == "Barney"); + TODO_ASSERT(db && db->getVariableFromVarId(2) && db->getVariableFromVarId(2)->type() && db->getVariableFromVarId(2)->type()->name() == "Wilma"); + ASSERT(db && db->getVariableFromVarId(3) && db->getVariableFromVarId(3)->type() && db->getVariableFromVarId(3)->type()->name() == "Barney"); } void isImplicitlyVirtual() {