parent
67b61a0ab7
commit
29001b651b
|
@ -1613,14 +1613,13 @@ void CheckOther::checkConstPointer()
|
||||||
const int indirect = p->isArray() ? p->dimensions().size() : 1;
|
const int indirect = p->isArray() ? p->dimensions().size() : 1;
|
||||||
if (isVariableChanged(start, p->scope()->bodyEnd, indirect, p->declarationId(), false, mSettings, mTokenizer->isCPP()))
|
if (isVariableChanged(start, p->scope()->bodyEnd, indirect, p->declarationId(), false, mSettings, mTokenizer->isCPP()))
|
||||||
continue;
|
continue;
|
||||||
if (p->isArgument() && 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;
|
|
||||||
if (p->typeStartToken() && !p->typeStartToken()->originalName().empty())
|
|
||||||
continue;
|
continue;
|
||||||
constVariableError(p, p->isArgument() ? p->scope()->function : nullptr);
|
constVariableError(p, p->isArgument() ? p->scope()->function : nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckOther::constVariableError(const Variable *var, const Function *function)
|
void CheckOther::constVariableError(const Variable *var, const Function *function)
|
||||||
{
|
{
|
||||||
if (!var) {
|
if (!var) {
|
||||||
|
|
|
@ -1926,20 +1926,24 @@ void TokenList::simplifyPlatformTypes()
|
||||||
Token *typeToken;
|
Token *typeToken;
|
||||||
if (platformtype->mConstPtr) {
|
if (platformtype->mConstPtr) {
|
||||||
tok->str("const");
|
tok->str("const");
|
||||||
tok->insertToken("*");
|
tok->isSimplifiedTypedef(true);
|
||||||
tok->insertToken(platformtype->mType);
|
tok->insertToken("*")->isSimplifiedTypedef(true);
|
||||||
|
tok->insertToken(platformtype->mType)->isSimplifiedTypedef(true);
|
||||||
typeToken = tok;
|
typeToken = tok;
|
||||||
} else if (platformtype->mPointer) {
|
} else if (platformtype->mPointer) {
|
||||||
tok->str(platformtype->mType);
|
tok->str(platformtype->mType);
|
||||||
|
tok->isSimplifiedTypedef(true);
|
||||||
typeToken = tok;
|
typeToken = tok;
|
||||||
tok->insertToken("*");
|
tok->insertToken("*")->isSimplifiedTypedef(true);
|
||||||
} else if (platformtype->mPtrPtr) {
|
} else if (platformtype->mPtrPtr) {
|
||||||
tok->str(platformtype->mType);
|
tok->str(platformtype->mType);
|
||||||
|
tok->isSimplifiedTypedef(true);
|
||||||
typeToken = tok;
|
typeToken = tok;
|
||||||
tok->insertToken("*");
|
tok->insertToken("*")->isSimplifiedTypedef(true);
|
||||||
tok->insertToken("*");
|
tok->insertToken("*")->isSimplifiedTypedef(true);
|
||||||
} else {
|
} else {
|
||||||
tok->str(platformtype->mType);
|
tok->str(platformtype->mType);
|
||||||
|
tok->isSimplifiedTypedef(true);
|
||||||
typeToken = tok;
|
typeToken = tok;
|
||||||
}
|
}
|
||||||
if (platformtype->mSigned)
|
if (platformtype->mSigned)
|
||||||
|
|
|
@ -3837,6 +3837,13 @@ private:
|
||||||
" qsort(p, nmemb, size, cmp);\n"
|
" qsort(p, nmemb, size, cmp);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void g(bool *r, std::size_t *b) {\n" // #12129
|
||||||
|
" if (*r && *b >= 5) {}\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:1]: (style) Parameter 'r' can be declared as pointer to const\n"
|
||||||
|
"[test.cpp:1]: (style) Parameter 'b' can be declared as pointer to const\n",
|
||||||
|
errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchRedundantAssignmentTest() {
|
void switchRedundantAssignmentTest() {
|
||||||
|
|
Loading…
Reference in New Issue