Skip to content

Commit 4eecf7b

Browse files
Fix #12402 debug: Function::addArguments found argument 'i' with vari… (#5975)
…d 0 for lambda parameter
1 parent 6bafd19 commit 4eecf7b

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

lib/tokenize.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4631,13 +4631,13 @@ void Tokenizer::setVarIdPass1()
46314631
}
46324632
}
46334633

4634-
if (!scopeStack.top().isStructInit &&
4635-
(tok == list.front() ||
4636-
Token::Match(tok, "[;{}]") ||
4637-
(tok->str() == "(" && isFunctionHead(tok,"{")) ||
4638-
(tok->str() == "(" && !scopeStack.top().isExecutable && isFunctionHead(tok,";:")) ||
4639-
(tok->str() == "," && (!scopeStack.top().isExecutable || inlineFunction || !tok->previous()->varId())) ||
4640-
(tok->isName() && endsWith(tok->str(), ':')))) {
4634+
if ((!scopeStack.top().isStructInit &&
4635+
(tok == list.front() ||
4636+
Token::Match(tok, "[;{}]") ||
4637+
(tok->str() == "(" && !scopeStack.top().isExecutable && isFunctionHead(tok,";:")) ||
4638+
(tok->str() == "," && (!scopeStack.top().isExecutable || inlineFunction || !tok->previous()->varId())) ||
4639+
(tok->isName() && endsWith(tok->str(), ':')))) ||
4640+
(tok->str() == "(" && isFunctionHead(tok, "{"))) {
46414641

46424642
// No variable declarations in sizeof
46434643
if (Token::simpleMatch(tok->previous(), "sizeof (")) {

test/testvarid.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2913,8 +2913,12 @@ class TestVarID : public TestFixture {
29132913
"}"));
29142914
}
29152915

2916-
void varid_arrayinit() { // #7579 - no variable declaration in rhs
2916+
void varid_arrayinit() {
2917+
// #7579 - no variable declaration in rhs
29172918
ASSERT_EQUALS("1: void foo ( int * a@1 ) { int b@2 [ 1 ] = { x * a@1 [ 0 ] } ; }\n", tokenize("void foo(int*a) { int b[] = { x*a[0] }; }"));
2919+
2920+
// #12402
2921+
ASSERT_EQUALS("1: void f ( ) { void ( * p@1 [ 1 ] ) ( int ) = { [ ] ( int i@2 ) { } } ; }\n", tokenize("void f() { void (*p[1])(int) = { [](int i) {} }; }"));
29182922
}
29192923

29202924
void varid_lambda_arg() {

0 commit comments

Comments
 (0)