missingReturn; Fixed FP when function is declared in macro

This commit is contained in:
Daniel Marjamäki 2021-07-08 13:14:11 +02:00
parent 4ecf3ccd17
commit ef0af26d9f
2 changed files with 4 additions and 1 deletions

View File

@ -259,7 +259,7 @@ void CheckFunctions::checkMissingReturn()
continue; continue;
if (function->type != Function::Type::eFunction && function->type != Function::Type::eOperatorEqual) if (function->type != Function::Type::eFunction && function->type != Function::Type::eOperatorEqual)
continue; continue;
if (Token::Match(function->retDef, "void %name%")) if (Token::Match(function->retDef, "void| %name% ("))
continue; continue;
const Token *errorToken = checkMissingReturnScope(scope->bodyEnd); const Token *errorToken = checkMissingReturnScope(scope->bodyEnd);
if (errorToken) if (errorToken)

View File

@ -1373,6 +1373,9 @@ private:
check("int f() {}"); 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()); 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 // switch
check("int f() {\n" check("int f() {\n"
" switch (x) {\n" " switch (x) {\n"