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

This commit is contained in:
Robert Reif 2010-02-23 22:12:55 +01:00 committed by Daniel Marjamäki
parent 4ef68546ef
commit d9df3d5c6e
2 changed files with 18 additions and 1 deletions

View File

@ -888,7 +888,7 @@ void Tokenizer::simplifyTypedef()
{
tok2 = tok2->next();
while (Token::Match(tok2, "*|&"))
while (Token::Match(tok2, "*|&") && tok2->next()->str() != ")")
tok2 = tok2->next();
// skip over typedef parameter

View File

@ -172,6 +172,7 @@ private:
TEST_CASE(simplifyTypedef33);
TEST_CASE(simplifyTypedef34); // ticket #1411
TEST_CASE(simplifyTypedef35);
TEST_CASE(simplifyTypedef36); // ticket #1434
TEST_CASE(reverseArraySyntax)
TEST_CASE(simplify_numeric_condition)
@ -3281,6 +3282,22 @@ private:
"[test.cpp:24] -> [test.cpp:1]: (style) Typedef 'A' hides typedef with same name\n", errout.str());
}
void simplifyTypedef36()
{
// ticket #1434
const char code[] = "typedef void (*TIFFFaxFillFunc)();\n"
"void f(va_list ap)\n"
"{\n"
" *va_arg(ap, TIFFFaxFillFunc*) = 0;\n"
"}";
const char expected[] = "; "
"void f ( va_list ap ) "
"{ "
"* va_arg ( ap , void ( * * ) ( ) ) = 0 ; "
"}";
ASSERT_EQUALS(expected, tok(code, false));
}
void reverseArraySyntax()
{
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));