diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 9c869bbcffd..9450cc72978 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -295,7 +295,7 @@ static std::pair getContainerFunction(c if (!tok || !tok->valueType() || (!tok->valueType()->container && (!(cont = library.detectContainerOrIterator(tok->valueType()->smartPointerTypeToken))))) return {}; const Token* parent = tok->astParent(); - if (Token::Match(parent, ". %name% (") && astIsLHS(tok)) { + if (Token::Match(parent, ". %name% [(<]") && astIsLHS(tok)) { return { parent->next(), cont ? cont : tok->valueType()->container }; } return {}; diff --git a/test/teststl.cpp b/test/teststl.cpp index c005ae125f4..4d1f14ae0f8 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -6956,6 +6956,13 @@ class TestStl : public TestFixture { " s += \'a\';\n" "}\n", dinit(CheckOptions, $.inconclusive = true)); ASSERT_EQUALS("", errout_str()); + + check("void f(std::vector::iterator it) {\n" // #13727 + " std::vector v;\n" + " v.insert::iterator>(v.end(), it, it + 1);\n" + " for (auto i : v) {}\n" + "}\n", dinit(CheckOptions, $.inconclusive = true)); + ASSERT_EQUALS("", errout_str()); } void checkMutexes() {