Fixed #10461 (FP missingReturn with empty initializer list)
This commit is contained in:
parent
42f66433bc
commit
47f5e5d145
|
@ -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() == "}") {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue