Fix 10339: Lambda in leads to analysis fail (#3629)
This commit is contained in:
parent
5f73af0d0e
commit
16110b6157
|
@ -8734,7 +8734,7 @@ void Tokenizer::simplifyIfSwitchForInit()
|
||||||
|
|
||||||
Token *semicolon = tok->tokAt(2);
|
Token *semicolon = tok->tokAt(2);
|
||||||
while (!Token::Match(semicolon, "[;)]")) {
|
while (!Token::Match(semicolon, "[;)]")) {
|
||||||
if (semicolon->str() == "(")
|
if (Token::Match(semicolon, "(|{|[") && semicolon->link())
|
||||||
semicolon = semicolon->link();
|
semicolon = semicolon->link();
|
||||||
semicolon = semicolon->next();
|
semicolon = semicolon->next();
|
||||||
}
|
}
|
||||||
|
|
|
@ -442,6 +442,7 @@ private:
|
||||||
TEST_CASE(simplifyIfSwitchForInit2);
|
TEST_CASE(simplifyIfSwitchForInit2);
|
||||||
TEST_CASE(simplifyIfSwitchForInit3);
|
TEST_CASE(simplifyIfSwitchForInit3);
|
||||||
TEST_CASE(simplifyIfSwitchForInit4);
|
TEST_CASE(simplifyIfSwitchForInit4);
|
||||||
|
TEST_CASE(simplifyIfSwitchForInit5);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define tokenizeAndStringify(...) tokenizeAndStringify_(__FILE__, __LINE__, __VA_ARGS__)
|
#define tokenizeAndStringify(...) tokenizeAndStringify_(__FILE__, __LINE__, __VA_ARGS__)
|
||||||
|
@ -7141,6 +7142,13 @@ private:
|
||||||
const char code[] = "void f() { for (a;b:c) {} }";
|
const char code[] = "void f() { for (a;b:c) {} }";
|
||||||
ASSERT_EQUALS("void f ( ) { { a ; for ( b : c ) { } } }", tokenizeAndStringify(code, settings));
|
ASSERT_EQUALS("void f ( ) { { a ; for ( b : c ) { } } }", tokenizeAndStringify(code, settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyIfSwitchForInit5() {
|
||||||
|
Settings settings;
|
||||||
|
settings.standards.cpp = Standards::CPP20;
|
||||||
|
const char code[] = "void f() { if ([] { ; }) {} }";
|
||||||
|
ASSERT_EQUALS("void f ( ) { if ( [ ] { ; } ) { } }", tokenizeAndStringify(code, settings));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestTokenizer)
|
REGISTER_TEST(TestTokenizer)
|
||||||
|
|
Loading…
Reference in New Issue