Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ void CheckOtherImpl::checkConstPointer()
// continue;
if (!isConstPointerVariable(p, mSettings))
continue;
if (p->typeStartToken() && p->typeStartToken()->isSimplifiedTypedef() && !(Token::simpleMatch(p->typeEndToken(), "*") && !p->typeEndToken()->isSimplifiedTypedef()))
if (p->typeStartToken() && p->typeStartToken()->isSimplifiedTypedef() && Token::simpleMatch(p->typeEndToken(), "*") && p->typeEndToken()->isSimplifiedTypedef())
continue;
constVariableError(p, p->isArgument() ? p->scope()->function : nullptr, foundAllBaseClasses);
}
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ void uninitvar()
// cppcheck-suppress uninitvar
lstrcat(buf, _T("test"));
buf[0] = _T('\0');
// TODO cppcheck-suppress constVariable
// cppcheck-suppress constVariable
TCHAR buf2[2];
// cppcheck-suppress lstrcatCalled
// cppcheck-suppress uninitvar
Expand Down
8 changes: 8 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4249,6 +4249,14 @@ class TestOther : public TestFixture {
" return &(u.i);\n"
"}\n");
ASSERT_EQUALS("", errout_str());

check("typedef int I;\n" // #15167
"I f() {\n"
" I a[1] = { 0 };\n"
" return a[0];\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3:7]: (style) Variable 'a' can be declared as const array [constVariable]\n",
errout_str());
}

void constParameterCallback() {
Expand Down
Loading