Skip to content

Commit 4f770a2

Browse files
committed
Fix
1 parent 13b50f4 commit 4f770a2

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎lib/astutils.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2369,7 +2369,7 @@ 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, "[+-]") && (!parent->valueType() || parent->valueType()->pointer))
2372+
if (Token::Match(parent, "[+-]") && (astIsPointer(parent) || astIsPointer(tok)))
23732373
parent = parent->astParent();
23742374

23752375
// passing variable to subfunction?

‎test/testother.cpp‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5104,10 +5104,20 @@ class TestOther : public TestFixture {
51045104
"U g(int* p, int n) {\n"
51055105
" return *(p + n);\n"
51065106
"}\n"
5107-
"auto h(int* p) {\n"
5107+
"auto h1(int* p) {\n"
51085108
" return *p;\n"
5109+
"}\n"
5110+
"void h2(int* p) {\n"
5111+
" g(h() + *p);\n"
5112+
"}\n"
5113+
"void h3(int* p) {\n"
5114+
" int* q = p;\n"
5115+
" g(h() - *q);\n"
51095116
"}\n");
5110-
ASSERT_EQUALS("[test.cpp:7:13]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n", errout_str());
5117+
ASSERT_EQUALS("[test.cpp:7:14]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n"
5118+
"[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",
5120+
errout_str());
51115121
}
51125122

51135123
void constArray() {

0 commit comments

Comments
 (0)