File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1580,7 +1580,7 @@ void CheckOther::checkConstPointer()
15801580 }
15811581 } else {
15821582 int argn = -1 ;
1583- if (Token::Match (parent, " %oror%|%comp%|&&|?|!|-" ))
1583+ if (Token::Match (parent, " %oror%|%comp%|&&|?|!|-|<< " ))
15841584 continue ;
15851585 if (Token::simpleMatch (parent, " (" ) && Token::Match (parent->astOperand1 (), " if|while" ))
15861586 continue ;
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ void ignoredReturnValue()
3939
4040void memleak ()
4141{
42- char * pBuf = (char *)cv::fastMalloc (1000 ); // cppcheck-suppress cstyleCast
42+ const char * pBuf = (char *)cv::fastMalloc (1000 ); // cppcheck-suppress cstyleCast
4343 std::cout << pBuf;
4444 // cppcheck-suppress memleak
4545}
Original file line number Diff line number Diff line change @@ -3882,6 +3882,13 @@ class TestOther : public TestFixture {
38823882 ASSERT_EQUALS (" [test.cpp:1]: (style) Parameter 'r' can be declared as pointer to const\n "
38833883 " [test.cpp:1]: (style) Parameter 'b' can be declared as pointer to const\n " ,
38843884 errout.str ());
3885+
3886+ check (" void f(int i) {\n " // #12185
3887+ " void* p = &i;\n "
3888+ " std::cout << p << '\\ n';\n "
3889+ " }\n " );
3890+ ASSERT_EQUALS (" [test.cpp:2]: (style) Variable 'p' can be declared as pointer to const\n " ,
3891+ errout.str ());
38853892 }
38863893
38873894 void switchRedundantAssignmentTest () {
@@ -8436,7 +8443,7 @@ class TestOther : public TestFixture {
84368443 " ptr = otherPtr;\n "
84378444 " free(otherPtr - xx - 1);\n "
84388445 " }" );
8439- ASSERT_EQUALS (" " , errout.str ());
8446+ ASSERT_EQUALS (" [test.cpp:2]: (style) Variable 'ptr' can be declared as pointer to const \n " , errout.str ());
84408447 }
84418448
84428449 void checkRedundantCopy () {
You can’t perform that action at this time.
0 commit comments