File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1658,7 +1658,7 @@ void CheckOther::checkConstPointer()
16581658 continue ;
16591659 if (deref != NONE) {
16601660 const Token* gparent = parent->astParent ();
1661- while (Token::simpleMatch (gparent, " [" ) && parent->str () == gparent->str ())
1661+ while (Token::simpleMatch (gparent, " [" ) && parent != gparent-> astOperand2 () && parent ->str () == gparent->str ())
16621662 gparent = gparent->astParent ();
16631663 if (deref == MEMBER) {
16641664 if (!gparent)
Original file line number Diff line number Diff line change @@ -4193,6 +4193,12 @@ class TestOther : public TestFixture {
41934193 " }\n " );
41944194 ASSERT_EQUALS (" [test.cpp:2]: (style) Parameter 's' can be declared as pointer to const\n " ,
41954195 errout_str ());
4196+
4197+ check (" void f(int* a, int* b, int i) {\n " // #13072
4198+ " a[b[i]] = 0;\n "
4199+ " }\n " );
4200+ ASSERT_EQUALS (" [test.cpp:1]: (style) Parameter 'b' can be declared as pointer to const\n " ,
4201+ errout_str ());
41964202 }
41974203
41984204 void constArray () {
You can’t perform that action at this time.
0 commit comments