Skip to content

Commit c3e9383

Browse files
Refs #13296: Fix FP clarifyCondition for cast to pointer to member function (#8577)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent 2cd2f46 commit c3e9383

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

lib/tokenlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ static bool iscast(const Token *tok, bool cpp)
547547
if (!Token::Match(tok2, "%name%|*|::"))
548548
return false;
549549

550-
if (tok2->isStandardType() && (tok2->strAt(1) != "(" || Token::Match(tok2->next(), "( * *| )")))
550+
if (tok2->isStandardType() && (tok2->strAt(1) != "(" || Token::simpleMatch(tok2->linkAt(1)->tokAt(-1), "* )")))
551551
type = true;
552552
}
553553

test/testtokenize.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8421,7 +8421,8 @@ class TestTokenizer : public TestFixture {
84218421

84228422
void ccast() {
84238423
const char code[] = "a = (int)x;\n" // #13579
8424-
"int (*p)[10];\n";
8424+
"int (*p)[10];\n"
8425+
"b = (void (S::*)(int) const)&y;";
84258426

84268427
SimpleTokenizer tokenizer(settingsDefault, *this);
84278428
ASSERT(tokenizer.tokenize(code));
@@ -8430,6 +8431,8 @@ class TestTokenizer : public TestFixture {
84308431
ASSERT(par->isCast());
84318432
par = Token::findsimplematch(par->next(), "(");
84328433
ASSERT(!par->isCast());
8434+
par = Token::findsimplematch(par->next(), "(");
8435+
ASSERT(par->isCast());
84338436
}
84348437

84358438
#define checkHdrs(...) checkHdrs_(__FILE__, __LINE__, __VA_ARGS__)

0 commit comments

Comments
 (0)