Skip to content

Commit ea544a4

Browse files
committed
Fix
1 parent 4f770a2 commit ea544a4

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎lib/astutils.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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?

‎test/testother.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)