Skip to content

Commit 47f5e5d

Browse files
committed
Fixed #10461 (FP missingReturn with empty initializer list)
1 parent 42f6643 commit 47f5e5d

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

lib/checkfunctions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ static const Token *checkMissingReturnScope(const Token *tok, const Library &lib
288288
{
289289
const Token *lastStatement = nullptr;
290290
while ((tok = tok->previous()) != nullptr) {
291+
if (tok->str() == ")")
292+
tok = tok->link();
291293
if (tok->str() == "{")
292294
return lastStatement ? lastStatement : tok->next();
293295
if (tok->str() == "}") {

test/testfunctions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,9 @@ class TestFunctions : public TestFixture {
14931493

14941494
check("int f(int x) { assert(0); }");
14951495
ASSERT_EQUALS("", errout.str());
1496+
1497+
check("int f(int x) { if (x) return 1; else return bar({1}, {}); }");
1498+
ASSERT_EQUALS("", errout.str());
14961499
}
14971500

14981501
// NRVO check

0 commit comments

Comments
 (0)