Skip to content

Commit 9433a25

Browse files
committed
Updated according to findings
Changed so that error message is in format "either ... or can be const" format. Added testcase with override, i.e. no warning.
1 parent 8037675 commit 9433a25

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/checkother.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,9 @@ void CheckOther::constVariableError(const Variable *var, const Function *functio
20512051

20522052
ErrorPath errorPath;
20532053
std::string id = "const" + vartype;
2054-
std::string message = "$symbol:" + varname + "\n" + vartype + " '$symbol' can be declared as " + ptrRefArray;
2054+
std::string message = !(inconclusive && *inconclusive) ?
2055+
"$symbol:" + varname + "\n" + vartype + " '$symbol' can be declared as " + ptrRefArray :
2056+
"$symbol:" + varname + "\nEither there is missing override/final keyword, or the " + vartype + " '$symbol' can be " + ptrRefArray;
20552057
errorPath.emplace_back(var->nameToken(), message);
20562058
if (var->isArgument() && function && function->functionPointerUsage) {
20572059
errorPath.emplace_front(function->functionPointerUsage, "You might need to cast the function pointer here");
@@ -2063,7 +2065,7 @@ void CheckOther::constVariableError(const Variable *var, const Function *functio
20632065
id += "Pointer";
20642066
}
20652067

2066-
reportError(std::move(errorPath), Severity::style, id.c_str(), message, CWE398, (inconclusive && *inconclusive) ? Certainty::inconclusive : Certainty::normal);
2068+
reportError(std::move(errorPath), Severity::style, id.c_str(), message, CWE398, Certainty::normal);
20672069
}
20682070

20692071
//---------------------------------------------------------------------------

0 commit comments

Comments
 (0)