Fix 10718: Crash in CheckOther::checkDuplicateExpression (#3713)
This commit is contained in:
parent
4af98f21d6
commit
89bc226738
|
@ -1721,7 +1721,7 @@ bool isUniqueExpression(const Token* tok)
|
||||||
if (f.type != Function::eFunction)
|
if (f.type != Function::eFunction)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const std::string freturnType = f.retType ? f.retType->name() : f.retDef->stringifyList(f.tokenDef);
|
const std::string freturnType = f.retType ? f.retType->name() : f.retDef->stringifyList(f.returnDefEnd());
|
||||||
if (f.argumentList.size() == fun->argumentList.size() &&
|
if (f.argumentList.size() == fun->argumentList.size() &&
|
||||||
returnType == freturnType &&
|
returnType == freturnType &&
|
||||||
f.name() != fun->name()) {
|
f.name() != fun->name()) {
|
||||||
|
|
|
@ -1258,6 +1258,9 @@ std::string Token::stringifyList(const stringifyOptions& options, const std::vec
|
||||||
unsigned int fileIndex = options.files ? ~0U : mImpl->mFileIndex;
|
unsigned int fileIndex = options.files ? ~0U : mImpl->mFileIndex;
|
||||||
std::map<int, unsigned int> lineNumbers;
|
std::map<int, unsigned int> lineNumbers;
|
||||||
for (const Token *tok = this; tok != end; tok = tok->next()) {
|
for (const Token *tok = this; tok != end; tok = tok->next()) {
|
||||||
|
assert(tok && "end precedes token");
|
||||||
|
if (!tok)
|
||||||
|
return ret;
|
||||||
bool fileChange = false;
|
bool fileChange = false;
|
||||||
if (tok->mImpl->mFileIndex != fileIndex) {
|
if (tok->mImpl->mFileIndex != fileIndex) {
|
||||||
if (fileIndex != ~0U) {
|
if (fileIndex != ~0U) {
|
||||||
|
|
|
@ -6179,6 +6179,17 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #10718
|
||||||
|
// Should probably not be inconclusive
|
||||||
|
check("struct a {\n"
|
||||||
|
" int b() const;\n"
|
||||||
|
" auto c() -> decltype(0) {\n"
|
||||||
|
" a d;\n"
|
||||||
|
" int e = d.b(), f = d.b();\n"
|
||||||
|
" return e + f;\n"
|
||||||
|
" }\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:5]: (style, inconclusive) Same expression used in consecutive assignments of 'e' and 'f'.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void multiConditionSameExpression() {
|
void multiConditionSameExpression() {
|
||||||
|
|
Loading…
Reference in New Issue