Fix simplifyTypedef crash on lambda. (#1054)
This commit is contained in:
parent
0f561d0ed6
commit
558e0757c2
|
@ -1045,8 +1045,10 @@ void Tokenizer::simplifyTypedef()
|
||||||
// check for member functions
|
// check for member functions
|
||||||
else if (isCPP() && Token::Match(tok2, ")|] const| {")) {
|
else if (isCPP() && Token::Match(tok2, ")|] const| {")) {
|
||||||
const Token *temp = tok2;
|
const Token *temp = tok2;
|
||||||
while (temp->str() == "]")
|
while (temp && temp->str() == "]" && temp->link() && temp->link()->previous())
|
||||||
temp = temp->link()->previous();
|
temp = temp->link()->previous();
|
||||||
|
if (!temp || !temp->link() || !temp->link()->previous())
|
||||||
|
continue;
|
||||||
const Token *func = temp->link()->previous();
|
const Token *func = temp->link()->previous();
|
||||||
if (temp->str() != ")")
|
if (temp->str() != ")")
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -159,6 +159,7 @@ private:
|
||||||
TEST_CASE(simplifyTypedef119); // ticket #7541
|
TEST_CASE(simplifyTypedef119); // ticket #7541
|
||||||
TEST_CASE(simplifyTypedef120); // ticket #8357
|
TEST_CASE(simplifyTypedef120); // ticket #8357
|
||||||
TEST_CASE(simplifyTypedef121); // ticket #5766
|
TEST_CASE(simplifyTypedef121); // ticket #5766
|
||||||
|
TEST_CASE(simplifyTypedef122); // segmentation fault
|
||||||
|
|
||||||
TEST_CASE(simplifyTypedefFunction1);
|
TEST_CASE(simplifyTypedefFunction1);
|
||||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||||
|
@ -2492,6 +2493,12 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyTypedef122() { // segmentation fault
|
||||||
|
const char code[] = "int result = [] { return git_run_cmd(\"update-index\",\"update-index -q --refresh\"); }();";
|
||||||
|
tok(code);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void simplifyTypedefFunction1() {
|
void simplifyTypedefFunction1() {
|
||||||
{
|
{
|
||||||
const char code[] = "typedef void (*my_func)();\n"
|
const char code[] = "typedef void (*my_func)();\n"
|
||||||
|
|
Loading…
Reference in New Issue