From ef0af26d9fab3ea5ae118400d512231e0084e066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 8 Jul 2021 13:14:11 +0200 Subject: [PATCH] missingReturn; Fixed FP when function is declared in macro --- lib/checkfunctions.cpp | 2 +- test/testfunctions.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index d441b6a6b..8904f3aea 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -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) diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index f728ba8c4..1ccf41099 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1373,6 +1373,9 @@ private: 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"