Skip to content

Commit

Permalink
missingReturn; Fixed FP when function is declared in macro
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Jul 8, 2021
1 parent 4ecf3cc commit ef0af26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checkfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void CheckFunctions::checkMissingReturn()
continue;
if (function->type != Function::Type::eFunction && function->type != Function::Type::eOperatorEqual)
continue;
if (Token::Match(function->retDef, "void %name%"))
if (Token::Match(function->retDef, "void| %name% ("))
continue;
const Token *errorToken = checkMissingReturnScope(scope->bodyEnd);
if (errorToken)
Expand Down
3 changes: 3 additions & 0 deletions test/testfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,9 @@ class TestFunctions : public TestFixture {
check("int f() {}");
ASSERT_EQUALS("[test.cpp:1]: (error) Found a exit path from function with non-void return type that has missing return statement\n", errout.str());

check("F(A,B) { x=1; }");
ASSERT_EQUALS("", errout.str());

// switch
check("int f() {\n"
" switch (x) {\n"
Expand Down

0 comments on commit ef0af26

Please sign in to comment.