Skip to content

Commit 99f7f88

Browse files
chrchr-githubchrchr-github
andauthored
Fix FN constParameterPointer (#5270)
Co-authored-by: chrchr-github <chrchr@github>
1 parent f10851d commit 99f7f88

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/astutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,7 @@ T* getTokenArgumentFunctionImpl(T* tok, int& argn)
21962196
parent = parent->astParent();
21972197

21982198
// passing variable to subfunction?
2199-
if (Token::Match(parent, "[(,{]"))
2199+
if (Token::Match(parent, "[[(,{]"))
22002200
;
22012201
else if (Token::simpleMatch(parent, ":")) {
22022202
while (Token::Match(parent, "[?:]"))

test/testother.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3754,6 +3754,13 @@ class TestOther : public TestFixture {
37543754
" p = q;\n"
37553755
"}\n");
37563756
ASSERT_EQUALS("", errout.str());
3757+
3758+
check("struct S { int a[1]; };\n"
3759+
"void f(S* s) {\n"
3760+
" if (s->a[0]) {}\n"
3761+
"}\n");
3762+
ASSERT_EQUALS("[test.cpp:2]: (style) Parameter 's' can be declared as pointer to const\n",
3763+
errout.str());
37573764
}
37583765

37593766
void switchRedundantAssignmentTest() {

0 commit comments

Comments
 (0)