Skip to content

Commit

Permalink
Skip template arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Feb 16, 2024
1 parent 40336c4 commit 8a0acf8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,11 @@ void CheckOther::warningOldStylePointerCast()
if (tok->str() != "(")
continue;
const Token* castTok = tok->next();
while (Token::Match(castTok, "const|volatile|class|struct|union|%type%|::"))
while (Token::Match(castTok, "const|volatile|class|struct|union|%type%|::")) {
castTok = castTok->next();
if (Token::simpleMatch(castTok, "<") && castTok->link())
castTok = castTok->link()->next();
}
if (castTok == tok->next() || !Token::simpleMatch(castTok, "*"))
continue;
while (Token::Match(castTok, "*|const|&"))
Expand Down
4 changes: 3 additions & 1 deletion test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1905,9 +1905,11 @@ class TestOther : public TestFixture {
"void f(void* p) {\n"
" auto ps = (N::S*)p;\n"
" auto pu = (union U*)p;\n"
" auto pv = (std::vector<int>*)(p);\n"
"}\n");
ASSERT_EQUALS("[test.cpp:7]: (style) C-style pointer casting\n"
"[test.cpp:8]: (style) C-style pointer casting\n",
"[test.cpp:8]: (style) C-style pointer casting\n"
"[test.cpp:9]: (style) C-style pointer casting\n",
errout.str());
}

Expand Down

0 comments on commit 8a0acf8

Please sign in to comment.