Fixed #1167 (### Internal error in Cppcheck. Please report it.)

This commit is contained in:
Robert Reif 2009-12-30 20:56:16 +01:00 committed by Daniel Marjamäki
parent 71a83647c6
commit f8f0a31e41
2 changed files with 34 additions and 0 deletions

View File

@ -603,10 +603,24 @@ void Tokenizer::simplifyTypedef()
{
tok2->str(start->str());
Token * nextToken;
std::list<Token *> links;
for (nextToken = start->next(); nextToken != end->next(); nextToken = nextToken->next())
{
tok2->insertToken(nextToken->strAt(0));
tok2 = tok2->next();
// Check for links and fix them up
if (tok2->str() == "(")
links.push_back(tok2);
if (tok2->str() == ")")
{
Token * link = links.back();
tok2->link(link);
link->link(tok2);
links.pop_back();
}
}
}
else

View File

@ -143,6 +143,7 @@ private:
TEST_CASE(simplifyTypedef6)
TEST_CASE(simplifyTypedef7);
TEST_CASE(simplifyTypedef8);
TEST_CASE(simplifyTypedef9);
TEST_CASE(reverseArraySyntax)
TEST_CASE(simplify_numeric_condition)
@ -2340,6 +2341,25 @@ private:
ASSERT_EQUALS(expected, tok(code, false));
}
void simplifyTypedef9()
{
// ticket # 1167
const char code[] = "typedef std::pair<int(*)(void*), void*> Func;"
"typedef std::vector<Func> CallQueue;"
"int main() {}";
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
// Clear the error buffer..
errout.str("");
tokenizer.simplifyTokenList();
ASSERT_EQUALS("", errout.str());
}
void reverseArraySyntax()
{
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));