Skip to content

Commit

Permalink
Fix FN constParameterPointer
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jul 26, 2023
1 parent d2546d5 commit e72e0df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,7 @@ T* getTokenArgumentFunctionImpl(T* tok, int& argn)
parent = parent->astParent();

// passing variable to subfunction?
if (Token::Match(parent, "[(,{]"))
if (Token::Match(parent, "[[(,{]"))
;
else if (Token::simpleMatch(parent, ":")) {
while (Token::Match(parent, "[?:]"))
Expand Down
7 changes: 7 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3754,6 +3754,13 @@ class TestOther : public TestFixture {
" p = q;\n"
"}\n");
ASSERT_EQUALS("", errout.str());

check("struct S { int a[1]; };\n"
"void f(S* s) {\n"
" if (s->a[0]) {}\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2]: (style) Parameter 's' can be declared as pointer to const\n",
errout.str());
}

void switchRedundantAssignmentTest() {
Expand Down

0 comments on commit e72e0df

Please sign in to comment.