Fixed #10461 (FP missingReturn with empty initializer list)

This commit is contained in:
Daniel Marjamäki 2021-09-06 21:20:19 +02:00
parent 42f66433bc
commit 47f5e5d145
2 changed files with 5 additions and 0 deletions

View File

@ -288,6 +288,8 @@ static const Token *checkMissingReturnScope(const Token *tok, const Library &lib
{
const Token *lastStatement = nullptr;
while ((tok = tok->previous()) != nullptr) {
if (tok->str() == ")")
tok = tok->link();
if (tok->str() == "{")
return lastStatement ? lastStatement : tok->next();
if (tok->str() == "}") {

View File

@ -1493,6 +1493,9 @@ private:
check("int f(int x) { assert(0); }");
ASSERT_EQUALS("", errout.str());
check("int f(int x) { if (x) return 1; else return bar({1}, {}); }");
ASSERT_EQUALS("", errout.str());
}
// NRVO check