File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -314,6 +314,8 @@ static const Token *checkMissingReturnScope(const Token *tok)
314314 }
315315 if (tok->isKeyword () && Token::Match (tok, " return|throw" ))
316316 return nullptr ;
317+ if (Token::Match (tok, " [;{}] %name% :" ))
318+ return tok;
317319 if (Token::Match (tok, " ; !!}" ) && !lastStatement)
318320 lastStatement = tok->next ();
319321 }
Original file line number Diff line number Diff line change @@ -1386,6 +1386,13 @@ class TestFunctions : public TestFixture {
13861386 " }" );
13871387 ASSERT_EQUALS (" " , errout.str ());
13881388
1389+ check (" int foo(int x) {\n "
1390+ " if (x) goto out;\n "
1391+ " return 1;\n "
1392+ " out:\n "
1393+ " }" );
1394+ ASSERT_EQUALS (" [test.cpp:3]: (error) Found a exit path from function with non-void return type that has missing return statement\n " , errout.str ());
1395+
13891396 // switch
13901397 check (" int f() {\n "
13911398 " switch (x) {\n "
You can’t perform that action at this time.
0 commit comments