diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 8cd0be9ff..2545c51f0 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -842,6 +842,12 @@ void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok) *tok = tok1; } + else + { + delete new_scope; + *scope = NULL; + *tok = NULL; + } } const Token *SymbolDatabase::initBaseInfo(Scope *scope, const Token *tok) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 8b069f954..c42a7151b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3303,7 +3303,7 @@ void Tokenizer::setVarId() // If pattern is "( %type% *|& %var% )" then check if it's a // variable declaration or a multiplication / mask - if (Token::Match(tok, "( %type% *|& %var% )") && !tok->next()->isStandardType()) + if (Token::Match(tok, "( %type% *|& %var% [),]") && !tok->next()->isStandardType()) { if (!Token::Match(tok->previous(), "%type%")) continue; @@ -7950,8 +7950,7 @@ void Tokenizer::simplifyStd() const Token *Tokenizer::getFunctionTokenByName(const char funcname[]) const { - if (_symbolDatabase == NULL) - getSymbolDatabase(); + getSymbolDatabase(); std::list::const_iterator i; @@ -7971,7 +7970,7 @@ const Token *Tokenizer::getFunctionTokenByName(const char funcname[]) const void Tokenizer::fillFunctionList() { - _symbolDatabase = new SymbolDatabase(this, _settings, _errorLogger); + getSymbolDatabase(); } //--------------------------------------------------------------------------- diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index ee5207b96..dfa87d3bb 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -2722,6 +2722,7 @@ private: void varidFunctionCall2() { + // #2491 const std::string code("void f(int b) {\n" " x(a*b,10);\n" "}"); @@ -2730,8 +2731,7 @@ private: "2: x ( a * b"); const std::string expected2(" , 10 ) ;\n" "3: }\n"); - TODO_ASSERT_EQUALS(expected1+"@1"+expected2, tokenizeDebugListing(code)); - ASSERT_EQUALS(expected1+"@2"+expected2, tokenizeDebugListing(code)); + ASSERT_EQUALS(expected1+"@1"+expected2, tokenizeDebugListing(code)); } void varidFunctionCall3() @@ -2751,7 +2751,6 @@ private: ASSERT_EQUALS(expected, tokenizeDebugListing(code)); } - void varidStl() { const std::string actual = tokenizeDebugListing(