File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2147,7 +2147,7 @@ void CheckOtherImpl::checkConstPointer()
21472147 // continue;
21482148 if (!isConstPointerVariable (p, mSettings ))
21492149 continue ;
2150- if (p->typeStartToken () && p->typeStartToken ()->isSimplifiedTypedef () && !( Token::simpleMatch (p->typeEndToken (), " *" ) && ! p->typeEndToken ()->isSimplifiedTypedef () ))
2150+ if (p->typeStartToken () && p->typeStartToken ()->isSimplifiedTypedef () && Token::simpleMatch (p->typeEndToken (), " *" ) && p->typeEndToken ()->isSimplifiedTypedef ())
21512151 continue ;
21522152 constVariableError (p, p->isArgument () ? p->scope ()->function : nullptr , foundAllBaseClasses);
21532153 }
Original file line number Diff line number Diff line change @@ -884,7 +884,7 @@ void uninitvar()
884884 // cppcheck-suppress uninitvar
885885 lstrcat (buf, _T (" test" ));
886886 buf[0 ] = _T (' \0 ' );
887- // TODO cppcheck-suppress constVariable
887+ // cppcheck-suppress constVariable
888888 TCHAR buf2[2 ];
889889 // cppcheck-suppress lstrcatCalled
890890 // cppcheck-suppress uninitvar
Original file line number Diff line number Diff line change @@ -4249,6 +4249,14 @@ class TestOther : public TestFixture {
42494249 " return &(u.i);\n"
42504250 "}\n");
42514251 ASSERT_EQUALS("", errout_str());
4252+
4253+ check("typedef int I;\n" // #15167
4254+ "I f() {\n"
4255+ " I a[1] = { 0 };\n"
4256+ " return a[0];\n"
4257+ "}\n");
4258+ ASSERT_EQUALS("[test.cpp:3:7]: (style) Variable 'a' can be declared as const array [constVariable]\n",
4259+ errout_str());
42524260 }
42534261
42544262 void constParameterCallback() {
You can’t perform that action at this time.
0 commit comments