Fix FP with ptr to ptr const (#4050)
This commit is contained in:
parent
80297acad0
commit
81f9b9b2b7
|
@ -1555,7 +1555,7 @@ void CheckOther::checkConstPointer()
|
||||||
continue;
|
continue;
|
||||||
if (!tok->valueType())
|
if (!tok->valueType())
|
||||||
continue;
|
continue;
|
||||||
if (tok->valueType()->pointer == 0 || (tok->valueType()->constness & 1))
|
if (tok->valueType()->pointer != 1 || (tok->valueType()->constness & 1) || tok->valueType()->reference != Reference::None)
|
||||||
continue;
|
continue;
|
||||||
if (nonConstPointers.find(tok->variable()) != nonConstPointers.end())
|
if (nonConstPointers.find(tok->variable()) != nonConstPointers.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -3035,6 +3035,20 @@ private:
|
||||||
" if (p == nullptr) {}\n"
|
" if (p == nullptr) {}\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void g(int*);\n"
|
||||||
|
"void f(int* const* pp) {\n"
|
||||||
|
" int* p = pp[0];\n"
|
||||||
|
" g(p);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("template <typename T>\n"
|
||||||
|
"struct S {\n"
|
||||||
|
" static bool f(const T& t) { return t != nullptr; }\n"
|
||||||
|
"};\n"
|
||||||
|
"S<int*> s;\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchRedundantAssignmentTest() {
|
void switchRedundantAssignmentTest() {
|
||||||
|
@ -9150,7 +9164,7 @@ private:
|
||||||
" int local_argc = 0;\n"
|
" int local_argc = 0;\n"
|
||||||
" local_argv[local_argc++] = argv[0];\n"
|
" local_argv[local_argc++] = argv[0];\n"
|
||||||
"}\n", "test.c");
|
"}\n", "test.c");
|
||||||
ASSERT_EQUALS("[test.c:1]: (style) Parameter 'argv' can be declared with const\n", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" int x = 0;\n"
|
" int x = 0;\n"
|
||||||
|
|
Loading…
Reference in New Issue