Skip to content

Commit ff0929a

Browse files
authored
Fix #14482 (False negative: missingReturn not reported for function that returns a std::int32_t) (#8256)
1 parent 959bfb1 commit ff0929a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/symboldatabase.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3342,8 +3342,12 @@ static bool checkReturns(const Function* function, bool unknown, bool emptyEnabl
33423342
assert(defEnd != defStart);
33433343
if (pred(defStart, defEnd))
33443344
return true;
3345-
if (isUnknownType(defStart, defEnd))
3345+
if (isUnknownType(defStart, defEnd)) {
3346+
const Token* tok = function->token ? function->token->next() : function->tokenDef->next();
3347+
if (tok->valueType() && tok->valueType()->type >= ValueType::Type::RECORD)
3348+
return false;
33463349
return unknown;
3350+
}
33473351
return false;
33483352
}
33493353

test/testfunctions.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class TestFunctions : public TestFixture {
8686
TEST_CASE(checkMissingReturn5);
8787
TEST_CASE(checkMissingReturn6); // #13180
8888
TEST_CASE(checkMissingReturn7); // #14370 - FN try/catch
89+
TEST_CASE(checkMissingReturnStdInt); // #14482 - FN std::int32_t
8990

9091
// std::move for locar variable
9192
TEST_CASE(returnLocalStdMove1);
@@ -1918,6 +1919,11 @@ class TestFunctions : public TestFixture {
19181919
ASSERT_EQUALS("[test.cpp:3:19]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str());
19191920
}
19201921

1922+
void checkMissingReturnStdInt() {// #14482 - FN
1923+
check("std::int32_t f() {}\n");
1924+
ASSERT_EQUALS("[test.cpp:1:19]: (error) Found an exit path from function with non-void return type that has missing return statement [missingReturn]\n", errout_str());
1925+
}
1926+
19211927
// NRVO check
19221928
void returnLocalStdMove1() {
19231929
check("struct A{}; A f() { A var; return std::move(var); }");

0 commit comments

Comments
 (0)