Skip to content

Commit 3d965b5

Browse files
Fix #11618 FP functionConst with call to static function (danmar#4898)
1 parent 19eef2c commit 3d965b5

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

lib/checkclass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2313,7 +2313,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, bool&
23132313
mayModifyArgs = false;
23142314
for (nonneg int argIndex = 0; argIndex < argMax; ++argIndex) {
23152315
const Variable* const argVar = f->getArgumentVar(argIndex);
2316-
if (!argVar || !argVar->valueType() || ((argVar->valueType()->pointer || argVar->valueType()->reference != Reference::None) && !argVar->isConst())) {
2316+
if (!argVar || ((argVar->isArrayOrPointer() || argVar->isReference()) && !argVar->isConst())) {
23172317
mayModifyArgs = true;
23182318
break;
23192319
}

test/testclass.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class TestClass : public TestFixture {
197197
TEST_CASE(const81); // ticket #11330
198198
TEST_CASE(const82); // ticket #11513
199199
TEST_CASE(const83);
200+
TEST_CASE(const84);
200201

201202
TEST_CASE(const_handleDefaultParameters);
202203
TEST_CASE(const_passThisToMemberOfOtherClass);
@@ -6360,6 +6361,19 @@ class TestClass : public TestFixture {
63606361
ASSERT_EQUALS("", errout.str());
63616362
}
63626363

6364+
void const84() { // #11618
6365+
checkConst("struct S {\n"
6366+
" int a[2], b[2];\n"
6367+
" void f() { f(a, b); }\n"
6368+
" static void f(const int p[2], int q[2]);\n"
6369+
"};\n"
6370+
"void S::f(const int p[2], int q[2]) {\n"
6371+
" q[0] = p[0];\n"
6372+
" q[1] = p[1];\n"
6373+
"}\n");
6374+
ASSERT_EQUALS("", errout.str());
6375+
}
6376+
63636377
void const_handleDefaultParameters() {
63646378
checkConst("struct Foo {\n"
63656379
" void foo1(int i, int j = 0) {\n"

0 commit comments

Comments
 (0)