Fix FN constParameterPointer (#5270)

Co-authored-by: chrchr-github <chrchr@github>
This commit is contained in:
chrchr-github 2023-07-27 20:54:12 +02:00 committed by GitHub
parent f10851dc37
commit 99f7f88f39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -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, "[?:]"))

View File

@ -3754,6 +3754,13 @@ private:
" 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() {