Fix output when note contains

This commit is contained in:
Daniel Marjamäki 2020-09-25 19:04:22 +02:00
parent 485153c930
commit bbd3a992b8
2 changed files with 8 additions and 2 deletions

View File

@ -1457,7 +1457,7 @@ void CheckOther::constVariableError(const Variable *var, const Function *functio
std::string message = "$symbol:" + varname + "\n" + vartype + " '$symbol' can be declared with const";
errorPath.push_back(ErrorPathItem(var ? var->nameToken() : nullptr, message));
if (var && var->isArgument() && function && function->functionPointerUsage) {
errorPath.push_back(ErrorPathItem(function->functionPointerUsage, "You might need to cast the function pointer here"));
errorPath.push_front(ErrorPathItem(function->functionPointerUsage, "You might need to cast the function pointer here"));
id += "Callback";
message += ". However it seems that '" + function->name() + "' is a callback function, if '$symbol' is declared with const you might also need to cast function pointer(s).";
}

View File

@ -151,7 +151,13 @@ ErrorMessage::ErrorMessage(const ErrorPath &errorPath, const TokenList *tokenLis
// Format callstack
for (const ErrorPathItem& e: errorPath) {
const Token *tok = e.first;
const std::string &info = e.second;
std::string info = e.second;
if (info.compare(0,8,"$symbol:") == 0 && info.find("\n") < info.size()) {
const std::string::size_type pos = info.find("\n");
const std::string &symbolName = info.substr(8, pos - 8);
info = replaceStr(info.substr(pos+1), "$symbol", symbolName);
}
// --errorlist can provide null values here
if (tok)