diff --git a/lib/checkother.cpp b/lib/checkother.cpp index f6f47c371..fb384ab5d 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3737,7 +3737,7 @@ void CheckOther::checkKnownArgument() continue; if (!Token::Match(tok->astParent(), "(|{|,")) continue; - if (tok->astParent()->isCast()) + if (tok->astParent()->isCast() || (tok->isCast() && Token::Match(tok->astOperand2(), "++|--|%assign%"))) continue; int argn = -1; const Token* ftok = getTokenArgumentFunction(tok, argn); diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 2ef1b5af8..a63062862 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -635,7 +635,7 @@ static void setTokenValue(Token* tok, // Ensure that the comma isn't a function call if (!callParent || (!Token::Match(callParent->previous(), "%name%|> (") && !Token::simpleMatch(callParent, "{") && (!Token::Match(callParent, "( %name%") || settings->library.isNotLibraryFunction(callParent->next())) && - !(callParent->str() == "(" && (Token::simpleMatch(callParent->astOperand1(), "*") || Token::Match(callParent->astOperand1(), "%name%"))))) { + !(callParent->str() == "(" && (Token::simpleMatch(callParent->astOperand1(), "*") || Token::Match(callParent->astOperand1(), "%name%|("))))) { setTokenValue(parent, std::move(value), settings); return; } diff --git a/test/testother.cpp b/test/testother.cpp index d6dfc0d63..0df3b2324 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -11074,6 +11074,17 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + check("struct S { void operator()(int, int); };\n" + "void f(int i) {\n" + " S()(i, 1);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + check("void f(int& r) {\n" + " g(static_cast(r = 42));\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + check("struct S { int i; };\n" "void f(int i) {\n" " const int a[] = { i - 1 * i, 0 };\n"