fix debug warning for function parameters with template with varid of 0

This commit is contained in:
Robert Reif 2011-04-28 20:53:31 -04:00
parent a2938b7212
commit e8eb20c6ef
2 changed files with 52 additions and 0 deletions

View File

@ -1265,8 +1265,27 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Function
}
else if (tok->str() == "[")
isArrayVar = true;
else if (tok->str() == "<")
{
int level = 1;
while (tok && tok->next())
{
tok = tok->next();
if (tok->str() == ">")
{
--level;
if (level == 0)
break;
}
else if (tok->str() == "<")
level++;
}
}
tok = tok->next();
if (!tok) // something is wrong so just bail
return;
}
// check for argument with no name or missing varid

View File

@ -100,6 +100,8 @@ private:
TEST_CASE(hasGlobalVariables1);
TEST_CASE(hasGlobalVariables2);
TEST_CASE(hasGlobalVariables3);
TEST_CASE(functionArgs1);
}
void test_isVariableDeclarationCanHandleNull()
@ -604,6 +606,37 @@ private:
}
}
}
void check(const char code[])
{
// Clear the error log
errout.str("");
// Check..
Settings settings;
settings.debugwarnings = true;
// Tokenize..
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.simplifyTokenList();
// force symbol database creation
tokenizer.getSymbolDatabase();
}
void functionArgs1()
{
check("void f(std::vector<std::string s>, const std::vector<int> & v) { }\n");
ASSERT_EQUALS("", errout.str());
check("void f(std::map<std::string, std::vector<int> > m) { }\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestSymbolDatabase)