File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1556,6 +1556,8 @@ void CheckOther::checkConstPointer()
15561556 deref = true ;
15571557 else if (Token::simpleMatch (parent, " [" ) && parent->astOperand1 () == tok && tok != nameTok)
15581558 deref = true ;
1559+ else if (Token::Match (parent, " %op%" ) && Token::simpleMatch (parent->astParent (), " ." ))
1560+ deref = true ;
15591561 else if (astIsRangeBasedForDecl (tok))
15601562 continue ;
15611563 if (deref) {
@@ -1577,7 +1579,7 @@ void CheckOther::checkConstPointer()
15771579 } else if (Token::simpleMatch (gparent, " [" ) && gparent->astOperand2 () == parent)
15781580 continue ;
15791581 } else {
1580- if (Token::Match (parent, " %oror%|%comp%|&&|?|!" ))
1582+ if (Token::Match (parent, " %oror%|%comp%|&&|?|!|- " ))
15811583 continue ;
15821584 else if (Token::simpleMatch (parent, " (" ) && Token::Match (parent->astOperand1 (), " if|while" ))
15831585 continue ;
Original file line number Diff line number Diff line change @@ -3250,6 +3250,13 @@ class TestOther : public TestFixture {
32503250 " **b = 0;\n "
32513251 " }\n " );
32523252 ASSERT_EQUALS (" " , errout.str ());
3253+
3254+ check (" ptrdiff_t f(int *p0, int *p1) {\n " // #11148
3255+ " return p0 - p1;\n "
3256+ " }\n " );
3257+ ASSERT_EQUALS (" [test.cpp:1]: (style) Parameter 'p0' can be declared as pointer to const\n "
3258+ " [test.cpp:1]: (style) Parameter 'p1' can be declared as pointer to const\n " ,
3259+ errout.str ());
32533260 }
32543261
32553262 void switchRedundantAssignmentTest () {
You can’t perform that action at this time.
0 commit comments