Revert "constPointer: Fix false positives when pointer is not read"
This reverts commit 6427b4888b
.
If variable/parameter is unused it is better to warn about that.
This commit is contained in:
parent
6427b4888b
commit
f2420509c9
|
@ -1540,6 +1540,8 @@ void CheckOther::checkConstPointer()
|
||||||
continue;
|
continue;
|
||||||
if (!tok->variable()->isLocal() && !tok->variable()->isArgument())
|
if (!tok->variable()->isLocal() && !tok->variable()->isArgument())
|
||||||
continue;
|
continue;
|
||||||
|
if (tok == tok->variable()->nameToken())
|
||||||
|
continue;
|
||||||
if (!tok->valueType())
|
if (!tok->valueType())
|
||||||
continue;
|
continue;
|
||||||
if (tok->valueType()->pointer == 0 || tok->valueType()->constness > 0)
|
if (tok->valueType()->pointer == 0 || tok->valueType()->constness > 0)
|
||||||
|
@ -1547,8 +1549,6 @@ void CheckOther::checkConstPointer()
|
||||||
if (nonConstPointers.find(tok->variable()) != nonConstPointers.end())
|
if (nonConstPointers.find(tok->variable()) != nonConstPointers.end())
|
||||||
continue;
|
continue;
|
||||||
pointers.insert(tok->variable());
|
pointers.insert(tok->variable());
|
||||||
if (tok == tok->variable()->nameToken())
|
|
||||||
continue;
|
|
||||||
const Token *parent = tok->astParent();
|
const Token *parent = tok->astParent();
|
||||||
bool deref = false;
|
bool deref = false;
|
||||||
if (parent && parent->isUnaryOp("*"))
|
if (parent && parent->isUnaryOp("*"))
|
||||||
|
|
|
@ -680,7 +680,7 @@ private:
|
||||||
"double* p1= new double[1];\n"
|
"double* p1= new double[1];\n"
|
||||||
"double* p2= new double[1];\n"
|
"double* p2= new double[1];\n"
|
||||||
"double* p3= new double[1];\n"
|
"double* p3= new double[1];\n"
|
||||||
" const double* pp[3] = {p1,p2,p3};\n"
|
"double* pp[3] = {p1,p2,p3};\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
@ -2778,9 +2778,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void constPointer() {
|
void constPointer() {
|
||||||
check("void foo(void* data) {}");
|
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (style) Parameter 'data' can be declared with const\n", errout.str());
|
|
||||||
|
|
||||||
check("void foo(int *p) { return *p; }");
|
check("void foo(int *p) { return *p; }");
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (style) Parameter 'p' can be declared with const\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (style) Parameter 'p' can be declared with const\n", errout.str());
|
||||||
|
|
||||||
|
@ -4754,7 +4751,7 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" const std::array<std::array<double,3>,3> array;\n"
|
" std::array<std::array<double,3>,3> array;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue