From 693b24d30aae416217aaed410c1074d8c766f181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 22 Jun 2020 14:31:34 +0200 Subject: [PATCH] Fix testrunner --- lib/checkother.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index ef983bdfc..c68c80dfa 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1200,11 +1200,12 @@ static bool canBeConst(const Variable *var) else if (parent->isAssignmentOp()) { if (parent->astOperand1() == tok2) return false; - else if (parent->astOperand1()->str() == "&") { - const Variable* assignedVar = parent->previous()->variable(); - if (!assignedVar || !assignedVar->isConst()) - return false; - } + const Variable* assignedVar = parent->astOperand1() ? parent->astOperand1()->variable() : nullptr; + if (assignedVar && + !assignedVar->isConst() && + assignedVar->isReference() && + assignedVar->nameToken() == parent->astOperand1()) + return false; } else if (Token::Match(tok2, "%var% . %name% (")) { const Function* func = tok2->tokAt(2)->function(); if (func && (func->isConst() || func->isStatic()))