diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 660cdf70c..10eedda9b 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -2178,8 +2178,6 @@ T* getTokenArgumentFunctionImpl(T* tok, int& argn) return nullptr; if (Token::simpleMatch(argtok, ",")) argtok = argtok->astOperand1(); - if (Token::simpleMatch(argtok, "(") && argtok->astOperand2()) - argtok = argtok->astOperand2(); tok = argtok; while (Token::Match(tok->astParent(), ",|(|{")) { tok = tok->astParent(); diff --git a/test/testastutils.cpp b/test/testastutils.cpp index a47ca1d10..f403e00c4 100644 --- a/test/testastutils.cpp +++ b/test/testastutils.cpp @@ -326,6 +326,8 @@ private: ASSERT(Result::True == isUsedAsBool("void f(bool b); void f() { int i; f(i); }","i )")); ASSERT(Result::True == isUsedAsBool("void f() { int *i; if (*i) {} }", "i )")); ASSERT(Result::True == isUsedAsBool("void f() { int *i; if (*i) {} }", "* i )")); + ASSERT(Result::True == isUsedAsBool("int g(); void h(bool); void f() { h(g()); }", "( ) )")); + ASSERT(Result::True == isUsedAsBool("int g(int); void h(bool); void f() { h(g(0)); }", "( 0 ) )")); } }; diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index e2c3c2193..933b22264 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -2749,6 +2749,14 @@ private: " v.data();\n" "}\n"); ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2] -> [test.cpp:3]: (error) Using object that is a temporary.\n", errout.str()); + + check("std::string convert(std::string_view sv) { return std::string{ sv }; }\n" // #11374 + "auto f() {\n" + " std::vector v;\n" + " v.push_back(convert(\"foo\"));\n" + " return v[0];\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void danglingLifetimeUniquePtr()