Fixed unreachableCode message if a lambda is returned (#6008).
This commit is contained in:
parent
353a9e9a64
commit
b5e064e737
|
@ -1120,7 +1120,7 @@ void CheckOther::checkUnreachableCode()
|
|||
else if (Token::Match(tok, "[;{}:] return|throw")) {
|
||||
tok = tok->next(); // tok should point to return or throw
|
||||
for (const Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) {
|
||||
if (tok2->str() == "(")
|
||||
if (tok2->str() == "(" || tok2->str() == "{")
|
||||
tok2 = tok2->link();
|
||||
if (tok2->str() == ";") {
|
||||
secondBreak = tok2->next();
|
||||
|
|
|
@ -2974,6 +2974,15 @@ private:
|
|||
" }));\n"
|
||||
"}", 0, false, false, false, false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #6008
|
||||
check("static std::function< int ( int, int ) > GetFunctor() {\n"
|
||||
" return [](int a_, int b_) -> int {\n"
|
||||
" int sum = a_ + b_;\n"
|
||||
" return sum;\n"
|
||||
" };\n"
|
||||
"}", 0, false, false, false, false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue