Fixed #8697 (noreturn output stream)

This commit is contained in:
Daniel Marjamäki 2018-08-21 06:32:33 +02:00
parent a30941d885
commit 866d198756
2 changed files with 16 additions and 0 deletions

View File

@ -904,6 +904,14 @@ bool Library::isScopeNoReturn(const Token *end, std::string *unknownFunc) const
if (unknownFunc) if (unknownFunc)
unknownFunc->clear(); 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), ") ; }")) if (!Token::simpleMatch(end->tokAt(-2), ") ; }"))
return false; return false;

View File

@ -3358,6 +3358,14 @@ private:
" x.front();\n" // <- unknown container size " x.front();\n" // <- unknown container size
"}"; "}";
ASSERT(tokenValues(code, "x . front").empty()); ASSERT(tokenValues(code, "x . front").empty());
code = "void f(std::vector<int> ints) {\n" // #8697
" if (ints.empty())\n"
" abort() << 123;\n"
" ints[0] = 0;\n"
"}";
ASSERT(tokenValues(code, "ints [").empty());
} }
}; };