Fix #10823 FP cstyleCast with function pointer and calling convention (#3853)

This commit is contained in:
chrchr-github 2022-02-23 09:12:14 +01:00 committed by GitHub
parent 51371f7929
commit f53793c413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -304,6 +304,8 @@ void CheckOther::warningOldStylePointerCast()
// Old style pointer casting.. // Old style pointer casting..
if (!Token::Match(tok, "( const|volatile| const|volatile|class|struct| %type% * const|&| ) (| %name%|%num%|%bool%|%char%|%str%")) if (!Token::Match(tok, "( const|volatile| const|volatile|class|struct| %type% * const|&| ) (| %name%|%num%|%bool%|%char%|%str%"))
continue; continue;
if (Token::Match(tok->previous(), "%type%"))
continue;
// skip first "const" in "const Type* const" // skip first "const" in "const Type* const"
while (Token::Match(tok->next(), "const|volatile|class|struct")) while (Token::Match(tok->next(), "const|volatile|class|struct"))

View File

@ -1503,6 +1503,12 @@ private:
ASSERT_EQUALS("[test.cpp:4]: (style) C-style pointer casting\n" ASSERT_EQUALS("[test.cpp:4]: (style) C-style pointer casting\n"
"[test.cpp:5]: (style) C-style pointer casting\n", "[test.cpp:5]: (style) C-style pointer casting\n",
errout.str()); errout.str());
// #10823
checkOldStylePointerCast("void f(void* p) {\n"
" auto h = reinterpret_cast<void (STDAPICALLTYPE*)(int)>(p);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }
#define checkInvalidPointerCast(...) checkInvalidPointerCast_(__FILE__, __LINE__, __VA_ARGS__) #define checkInvalidPointerCast(...) checkInvalidPointerCast_(__FILE__, __LINE__, __VA_ARGS__)