File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -1857,10 +1857,13 @@ void CheckOther::checkConstPointer()
18571857 if (!var->isLocal () && !var->isArgument ())
18581858 continue ;
18591859 const Token* const nameTok = var->nameToken ();
1860- if (tok == nameTok) {
1860+ if (tok == nameTok && var->isLocal () && !astIsRangeBasedForDecl (nameTok)) {
1861+ if (var->isReference () && var->isPointer ()) {
1862+ nonConstPointers.emplace (var);
1863+ continue ;
1864+ }
18611865 // declarations of (static) pointers are (not) split up, array declarations are never split up
1862- if (var->isLocal () && (!var->isStatic () || Token::simpleMatch (nameTok->next (), " [" )) &&
1863- !astIsRangeBasedForDecl (nameTok))
1866+ if ((!var->isStatic () || Token::simpleMatch (nameTok->next (), " [" )))
18641867 continue ;
18651868 }
18661869 // Skip function pointers
Original file line number Diff line number Diff line change @@ -4004,6 +4004,12 @@ class TestOther : public TestFixture {
40044004 " return static_cast<const D&>(b).i;\n"
40054005 "}\n");
40064006 ASSERT_EQUALS("[test.cpp:9:10]: (style) Parameter 'b' can be declared as reference to const [constParameterReference]\n", errout_str());
4007+
4008+ check("void f(int *p) {\n" // #14409
4009+ " int*& pp{ p };\n"
4010+ " if (*pp) {}\n"
4011+ "}\n");
4012+ ASSERT_EQUALS("", errout_str());
40074013 }
40084014
40094015 void constParameterCallback() {
You can’t perform that action at this time.
0 commit comments