@@ -1727,6 +1727,10 @@ static void execute(const Token *expr,
17271727 if (!expr)
17281728 *error = true ;
17291729
1730+ else if (expr->values .size () == 1U && expr->values .front ().isKnown () && !expr->values .front ().tokvalue ) {
1731+ *result = expr->values .front ().intvalue ;
1732+ }
1733+
17301734 else if (expr->isNumber ()) {
17311735 *result = MathLib::toLongNumber (expr->str ());
17321736 if (MathLib::isFloat (expr->str ()))
@@ -1838,16 +1842,22 @@ static void execute(const Token *expr,
18381842 }
18391843
18401844 else if (expr->str () == " [" && expr->astOperand1 () && expr->astOperand2 ()) {
1841- if (expr->astOperand1 ()->values .size () != 1U ) {
1842- *error = true ;
1843- return ;
1845+ const Token *tokvalue = nullptr ;
1846+ std::map<unsigned int , const Token *>::iterator var = programMemory->tokvalues .find (expr->astOperand1 ()->varId ());
1847+ if (var != programMemory->tokvalues .end ()) {
1848+ tokvalue = var->second ;
1849+ } else {
1850+ if (expr->astOperand1 ()->values .size () != 1U ) {
1851+ *error = true ;
1852+ return ;
1853+ }
1854+ tokvalue = expr->astOperand1 ()->values .front ().tokvalue ;
18441855 }
1845- const ValueFlow::Value val = expr->astOperand1 ()->values .front ();
1846- if (!val.tokvalue || !val.tokvalue ->isLiteral ()) {
1856+ if (!tokvalue || !tokvalue->isLiteral ()) {
18471857 *error = true ;
18481858 return ;
18491859 }
1850- const std::string strValue = val. tokvalue ->strValue ();
1860+ const std::string strValue = tokvalue->strValue ();
18511861 MathLib::bigint index = 0 ;
18521862 execute (expr->astOperand2 (), programMemory, &index, error);
18531863 if (index >= 0 && index < strValue.size ())
0 commit comments