Fixed #1782 ((error) ### Internal error in Cppcheck. Please report it.)
This commit is contained in:
parent
e64ce2e812
commit
6b65b77acf
|
@ -1428,7 +1428,18 @@ void Tokenizer::simplifyTypedef()
|
||||||
tok2 = tok2->next();
|
tok2 = tok2->next();
|
||||||
|
|
||||||
// skip over name
|
// skip over name
|
||||||
tok2 = tok2->next();
|
if (tok2->next()->str() != ")")
|
||||||
|
{
|
||||||
|
tok2 = tok2->next();
|
||||||
|
|
||||||
|
// check for function and skip over args
|
||||||
|
if (tok2->next()->str() == "(")
|
||||||
|
tok2 = tok2->next()->link();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// syntax error
|
||||||
|
}
|
||||||
|
|
||||||
tok2->insertToken(")");
|
tok2->insertToken(")");
|
||||||
Token::createMutualLinks(tok2->next(), tok3);
|
Token::createMutualLinks(tok2->next(), tok3);
|
||||||
|
|
|
@ -200,6 +200,7 @@ private:
|
||||||
TEST_CASE(simplifyTypedef49); // ticket #1691
|
TEST_CASE(simplifyTypedef49); // ticket #1691
|
||||||
TEST_CASE(simplifyTypedef50);
|
TEST_CASE(simplifyTypedef50);
|
||||||
TEST_CASE(simplifyTypedef51);
|
TEST_CASE(simplifyTypedef51);
|
||||||
|
TEST_CASE(simplifyTypedef52); // ticket #1782
|
||||||
|
|
||||||
TEST_CASE(simplifyTypedefFunction1);
|
TEST_CASE(simplifyTypedefFunction1);
|
||||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||||
|
@ -4066,6 +4067,31 @@ private:
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyTypedef52() // ticket #1782
|
||||||
|
{
|
||||||
|
{
|
||||||
|
const char code[] = "typedef char (* type1)[10];\n"
|
||||||
|
"type1 foo() { }";
|
||||||
|
|
||||||
|
// The expected result..
|
||||||
|
const std::string expected("; "
|
||||||
|
"char ( * foo ( ) ) [ 10 ] { }");
|
||||||
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
|
|
||||||
|
checkSimplifyTypedef(code);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const char code[] = "typedef char (* type1)[10];\n"
|
||||||
|
"LOCAL(type1) foo() { }";
|
||||||
|
|
||||||
|
// this is invalid C so just make sure it doesn't generate an internal error
|
||||||
|
checkSimplifyTypedef(code);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void simplifyTypedefFunction1()
|
void simplifyTypedefFunction1()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue