Fixed #4799 (Segmentation fault in K&R simplification inside lambda expression)
This commit is contained in:
parent
b58e1241dc
commit
0943fecf03
|
@ -5005,7 +5005,7 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, Token * tokEnd, bool only_k_r_
|
||||||
continue;
|
continue;
|
||||||
} else if (tok->str() == "(") {
|
} else if (tok->str() == "(") {
|
||||||
for (Token * tok2 = tok; tok2 != tok->link(); tok2 = tok2->next()) {
|
for (Token * tok2 = tok; tok2 != tok->link(); tok2 = tok2->next()) {
|
||||||
if (isCPP() && Token::Match(tok2, "[(,] [")) {
|
if (!only_k_r_fpar && isCPP() && Token::Match(tok2, "[(,] [")) {
|
||||||
// lambda function at tok2->next()
|
// lambda function at tok2->next()
|
||||||
// find start of lambda body
|
// find start of lambda body
|
||||||
Token * lambdaBody = tok2;
|
Token * lambdaBody = tok2;
|
||||||
|
|
|
@ -361,6 +361,7 @@ private:
|
||||||
TEST_CASE(vardecl22); // #4211 - segmentation fault
|
TEST_CASE(vardecl22); // #4211 - segmentation fault
|
||||||
TEST_CASE(vardecl23); // #4276 - segmentation fault
|
TEST_CASE(vardecl23); // #4276 - segmentation fault
|
||||||
TEST_CASE(vardecl24); // #4187 - variable declaration within lambda function
|
TEST_CASE(vardecl24); // #4187 - variable declaration within lambda function
|
||||||
|
TEST_CASE(vardecl25); // #4799 - segmentation fault
|
||||||
TEST_CASE(vardecl_stl_1);
|
TEST_CASE(vardecl_stl_1);
|
||||||
TEST_CASE(vardecl_stl_2);
|
TEST_CASE(vardecl_stl_2);
|
||||||
TEST_CASE(vardecl_template_1);
|
TEST_CASE(vardecl_template_1);
|
||||||
|
@ -5757,6 +5758,13 @@ private:
|
||||||
ASSERT_EQUALS(expected2, tokenizeAndStringify(code2));
|
ASSERT_EQUALS(expected2, tokenizeAndStringify(code2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vardecl25() { // #4799 - segmentation fault
|
||||||
|
tokenizeAndStringify("void A::func(P g) const {}\n"
|
||||||
|
"void A::a() {\n"
|
||||||
|
" b = new d( [this]( const P & p) -> double { return this->func(p);} );\n"
|
||||||
|
"}");
|
||||||
|
}
|
||||||
|
|
||||||
void volatile_variables() {
|
void volatile_variables() {
|
||||||
const char code[] = "volatile int a=0;\n"
|
const char code[] = "volatile int a=0;\n"
|
||||||
"volatile int b=0;\n"
|
"volatile int b=0;\n"
|
||||||
|
|
Loading…
Reference in New Issue