missingReturn; ensure Function::returnsVoid returns true when there is unknown macro 'void STDCALL foo() {}'

This commit is contained in:
Daniel Marjamäki 2021-07-12 20:29:20 +02:00
parent e4ecfd7be8
commit 24c17916af
2 changed files with 12 additions and 0 deletions

View File

@ -2689,6 +2689,15 @@ bool Function::returnsVoid(const Function* function, bool unknown)
// Check for unknown types, which could be a void type
if (isUnknownType(function->retDef, defEnd))
return unknown;
if (unknown) {
// void STDCALL foo()
const Token *def;
bool isVoid = false;
for (def = function->retDef; def && def->isName(); def = def->next())
isVoid |= (def->str() == "void");
if (isVoid && def && !Token::Match(def, "*|&|&&"))
return true;
}
return false;
}

View File

@ -1379,6 +1379,9 @@ private:
check("auto foo4() -> void {}");
ASSERT_EQUALS("", errout.str());
check("void STDCALL foo() {}");
ASSERT_EQUALS("", errout.str());
check("int f() {\n"
"back:\n"
" return 0;\n"