diff --git a/lib/programmemory.cpp b/lib/programmemory.cpp index af86ef98318..8e9f678d7d1 100644 --- a/lib/programmemory.cpp +++ b/lib/programmemory.cpp @@ -1411,18 +1411,34 @@ namespace { ValueFlow::Value executeImpl(const Token* expr) { - const ValueFlow::Value* value = nullptr; if (!expr) return unknown(); - if (expr->hasKnownIntValue() && !expr->isAssignmentOp() && expr->str() != ",") - return expr->values().front(); - if ((value = expr->getKnownValue(ValueFlow::Value::ValueType::FLOAT)) || - (value = expr->getKnownValue(ValueFlow::Value::ValueType::TOK)) || - (value = expr->getKnownValue(ValueFlow::Value::ValueType::ITERATOR_START)) || - (value = expr->getKnownValue(ValueFlow::Value::ValueType::ITERATOR_END)) || - (value = expr->getKnownValue(ValueFlow::Value::ValueType::CONTAINER_SIZE))) { - return *value; + const ValueFlow::Value* value = nullptr; + for (const auto& val : expr->values()) + { + if (!val.isKnown()) + continue; + switch (val.valueType) { + case ValueFlow::Value::ValueType::INT: { + if (!expr->isAssignmentOp() && expr->str() != ",") + return expr->values().front(); + break; + } + case ValueFlow::Value::ValueType::FLOAT: + case ValueFlow::Value::ValueType::TOK: + case ValueFlow::Value::ValueType::ITERATOR_START: + case ValueFlow::Value::ValueType::ITERATOR_END: + case ValueFlow::Value::ValueType::CONTAINER_SIZE: { + if (!value) + value = &val; + break; + } + default: + break; + } } + if (value) + return *value; if (expr->isNumber()) { if (MathLib::isFloat(expr->str())) return unknown();