diff --git a/lib/library.cpp b/lib/library.cpp index 3a853ed07..ccf325872 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -904,6 +904,14 @@ bool Library::isScopeNoReturn(const Token *end, std::string *unknownFunc) const if (unknownFunc) unknownFunc->clear(); + if (Token::Match(end->tokAt(-2), "!!{ ; }")) { + const Token *lastTop = end->tokAt(-2)->astTop(); + if (Token::simpleMatch(lastTop, "<<") && + Token::simpleMatch(lastTop->astOperand1(), "(") && + Token::Match(lastTop->astOperand1()->previous(), "%name% (")) + return isnoreturn(lastTop->astOperand1()->previous()); + } + if (!Token::simpleMatch(end->tokAt(-2), ") ; }")) return false; diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 9afd51b11..92482c2ba 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -3358,6 +3358,14 @@ private: " x.front();\n" // <- unknown container size "}"; ASSERT(tokenValues(code, "x . front").empty()); + + code = "void f(std::vector ints) {\n" // #8697 + " if (ints.empty())\n" + " abort() << 123;\n" + " ints[0] = 0;\n" + "}"; + ASSERT(tokenValues(code, "ints [").empty()); + } };