Fix #11171 FP missing return statement when std::enable_if_t is used (#4480)

* Fix #11171 FP missing return statement when std::enable_if_t is used

* Add check
This commit is contained in:
chrchr-github 2022-09-19 12:47:58 +02:00 committed by GitHub
parent 8275f07692
commit f274d499a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -310,6 +310,8 @@ void CheckFunctions::checkMissingReturn()
continue;
if (Token::Match(function->retDef, "%name% (") && function->retDef->isUpperCaseName())
continue;
if (mTokenizer->isCPP() && Token::Match(function->retDef, "std :: enable_if|enable_if_t"))
continue;
if (Function::returnsVoid(function, true))
continue;
const Token *errorToken = checkMissingReturnScope(scope->bodyEnd, mSettings->library);

View File

@ -1725,6 +1725,9 @@ private:
ASSERT_EQUALS("[test.cpp:2]: (error) Found a exit path from function with non-void return type that has missing return statement\n"
"[test.cpp:10]: (error) Found a exit path from function with non-void return type that has missing return statement\n",
errout.str());
check("std::enable_if_t<sizeof(uint64_t) == 8> f() {}"); // #11171
ASSERT_EQUALS("", errout.str());
}
// NRVO check