Fixed #1167 (### Internal error in Cppcheck. Please report it.)
This commit is contained in:
parent
71a83647c6
commit
f8f0a31e41
|
@ -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
|
||||
|
|
|
@ -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]"));
|
||||
|
|
Loading…
Reference in New Issue