File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2369,7 +2369,8 @@ static T* getTokenArgumentFunctionImpl(T* tok, int& argn)
23692369 parent = parent->astParent ();
23702370 while (parent && parent->isCast ())
23712371 parent = parent->astParent ();
2372- if (Token::Match (parent, " [+-]" ) && (astIsPointer (parent) || astIsPointer (tok)))
2372+ if (Token::Match (parent, " [+-]" ) && (astIsPointer (parent) ||
2373+ (astIsPointer (tok) && !(astIsPointer (parent->astOperand1 ()) && astIsPointer (parent->astOperand2 ())))))
23732374 parent = parent->astParent ();
23742375
23752376 // passing variable to subfunction?
Original file line number Diff line number Diff line change @@ -5113,10 +5113,15 @@ class TestOther : public TestFixture {
51135113 "void h3(int* p) {\n"
51145114 " int* q = p;\n"
51155115 " g(h() - *q);\n"
5116+ "}\n"
5117+ "void h4(int* p, int* q) {\n"
5118+ " g(p - q);\n"
51165119 "}\n");
51175120 ASSERT_EQUALS("[test.cpp:7:14]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n"
51185121 "[test.cpp:10:14]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n"
5119- "[test.cpp:14:10]: (style) Variable 'q' can be declared as pointer to const [constVariablePointer]\n",
5122+ "[test.cpp:14:10]: (style) Variable 'q' can be declared as pointer to const [constVariablePointer]\n"
5123+ "[test.cpp:17:14]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n"
5124+ "[test.cpp:17:22]: (style) Parameter 'q' can be declared as pointer to const [constParameterPointer]\n",
51205125 errout_str());
51215126 }
51225127
You can’t perform that action at this time.
0 commit comments