Fix FN constParameterReference with std::array (#4999)

This commit is contained in:
chrchr-github 2023-04-21 20:33:06 +02:00 committed by GitHub
parent bda9f707cc
commit 5c7914aaa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -1424,7 +1424,7 @@ void CheckOther::checkConstVariable()
continue;
if (var->isStatic())
continue;
if (var->isArray())
if (var->isArray() && !var->isStlType())
continue;
if (var->isEnumType())
continue;

View File

@ -3107,6 +3107,14 @@ private:
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void f(std::array<int, 2>& a) {\n"
" if (a[0]) {}\n"
"}\n"
"void g(std::array<int, 2>& a) {\n"
" a.fill(0);\n"
"}\n");
ASSERT_EQUALS("[test.cpp:1]: (style) Parameter 'a' can be declared as const array\n", errout.str());
}
void constParameterCallback() {