Fixed #1411 (### Internal error in Cppcheck. Please report it.)
This commit is contained in:
parent
9e61e7dda8
commit
5c6ec0364d
|
@ -774,10 +774,13 @@ void Tokenizer::simplifyTypedef()
|
||||||
{
|
{
|
||||||
if (tok2->next()->str() == "(")
|
if (tok2->next()->str() == "(")
|
||||||
tok2 = tok2->next()->link();
|
tok2 = tok2->next()->link();
|
||||||
else
|
else if (tok2->next()->str() != "[")
|
||||||
{
|
{
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
|
|
||||||
|
while (Token::Match(tok2, "*|&"))
|
||||||
|
tok2 = tok2->next();
|
||||||
|
|
||||||
// skip over typedef parameter
|
// skip over typedef parameter
|
||||||
if (tok2->next()->str() == "(")
|
if (tok2->next()->str() == "(")
|
||||||
{
|
{
|
||||||
|
|
|
@ -170,6 +170,7 @@ private:
|
||||||
TEST_CASE(simplifyTypedef31);
|
TEST_CASE(simplifyTypedef31);
|
||||||
TEST_CASE(simplifyTypedef32);
|
TEST_CASE(simplifyTypedef32);
|
||||||
TEST_CASE(simplifyTypedef33);
|
TEST_CASE(simplifyTypedef33);
|
||||||
|
TEST_CASE(simplifyTypedef34); // ticket #1411
|
||||||
TEST_CASE(reverseArraySyntax)
|
TEST_CASE(reverseArraySyntax)
|
||||||
TEST_CASE(simplify_numeric_condition)
|
TEST_CASE(simplify_numeric_condition)
|
||||||
|
|
||||||
|
@ -3167,6 +3168,26 @@ private:
|
||||||
ASSERT_EQUALS(expected, tok(code, false));
|
ASSERT_EQUALS(expected, tok(code, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyTypedef34()
|
||||||
|
{
|
||||||
|
// ticket #1411
|
||||||
|
const char code[] = "class X { };\n"
|
||||||
|
"typedef X (*foofunc)(const X&);\n"
|
||||||
|
"int main()\n"
|
||||||
|
"{\n"
|
||||||
|
" foofunc *Foo = new foofunc[2];\n"
|
||||||
|
"}";
|
||||||
|
const char expected[] =
|
||||||
|
"class X { } ; "
|
||||||
|
"; "
|
||||||
|
"int main ( ) "
|
||||||
|
"{ "
|
||||||
|
"X ( * * Foo ) ( const X & ) = new X ( * ) ( const X & ) [ 2 ] ; "
|
||||||
|
"}";
|
||||||
|
|
||||||
|
ASSERT_EQUALS(expected, tok(code, false));
|
||||||
|
}
|
||||||
|
|
||||||
void reverseArraySyntax()
|
void reverseArraySyntax()
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
||||||
|
|
Loading…
Reference in New Issue