From 24c17916af4bb4204cfb32f01378f6d4c1853d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 12 Jul 2021 20:29:20 +0200 Subject: [PATCH] missingReturn; ensure Function::returnsVoid returns true when there is unknown macro 'void STDCALL foo() {}' --- lib/symboldatabase.cpp | 9 +++++++++ test/testfunctions.cpp | 3 +++ 2 files changed, 12 insertions(+) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 9f771feff..832db5f20 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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; } diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index b3495c0cf..3230829f6 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -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"