CheckStl::readingEmptyStlContainer(): Skip over lambdas (#8055)
This commit is contained in:
parent
c1cdcc158f
commit
b345c430fe
|
@ -1551,7 +1551,8 @@ void CheckStl::readingEmptyStlContainer()
|
|||
}
|
||||
} else if (Token::Match(tok, "do|}|break|case")) {
|
||||
emptyContainer.clear();
|
||||
}
|
||||
} else if (tok->str() == "{" && tok->next()->scope()->type == Scope::eLambda)
|
||||
tok = tok->link();
|
||||
|
||||
if (!tok->varId())
|
||||
continue;
|
||||
|
|
|
@ -3019,6 +3019,18 @@ private:
|
|||
" it = test.end();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #8055
|
||||
check("int main() {\n"
|
||||
" std::string str;\n"
|
||||
" auto l = [&]() {\n"
|
||||
" if (str[0] == 'A')\n"
|
||||
" std::cout << \"!\";\n"
|
||||
" }\n"
|
||||
" str = \"A\";\n"
|
||||
" l();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue