diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index 4e53434c0..dc0bd5a92 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -606,7 +606,7 @@ static ExprEngine::ValuePtr executeExpression(const Token *tok, Data &data) if (tok->astOperand1() && tok->astOperand2() && tok->str() == "[") return executeArrayIndex(tok, data); - if (tok->str() == "(" && tok->astOperand2()) + if (tok->str() == "(" && !tok->isCast()) return executeFunctionCall(tok, data); if (tok->str() == ".") diff --git a/test/testexprengine.cpp b/test/testexprengine.cpp index 93ce43a39..442a10368 100644 --- a/test/testexprengine.cpp +++ b/test/testexprengine.cpp @@ -41,6 +41,7 @@ private: TEST_CASE(exprAssign1); TEST_CASE(functionCall1); + TEST_CASE(functionCall2); TEST_CASE(if1); TEST_CASE(if2); @@ -127,6 +128,17 @@ private: ASSERT_EQUALS("-2147483648:2147483647", getRange("int atoi(const char *p); void f() { int x = atoi(a); x = x; }", "x=x")); } + void functionCall2() { + const char code[] = "namespace NS {\n" + " short getValue();\n" + "}" + "void f() {\n" + " short value = NS::getValue();\n" + " value = value;\n" + "}"; + ASSERT_EQUALS("-32768:32767", getRange(code, "value=value")); + } + void if1() { ASSERT_EQUALS("7:32768", getRange("inf f(short x) { if (x > 5) a = x + 1; }", "x+1")); }