Fixed #8190 (False positive constStatement - return (struct media_frames_per_second) {0};)

This commit is contained in:
Daniel Marjamäki 2017-09-21 22:50:46 +02:00
parent 89b9f57759
commit 411c5e5f7e
2 changed files with 7 additions and 9 deletions

View File

@ -1571,20 +1571,13 @@ void CheckOther::checkIncompleteStatement()
if (Token::Match(tok, "(|["))
tok = tok->link();
else if (Token::simpleMatch(tok, "= {"))
tok = tok->next()->link();
else if (tok->str() == "{" && tok->astParent())
tok = tok->link();
// C++11 struct/array/etc initialization in initializer list
else if (Token::Match(tok->previous(), "%name%|] {") && !Token::findsimplematch(tok,";",tok->link()))
tok = tok->link();
// C++11 vector initialization / return { .. }
else if (Token::Match(tok,"> %name% {") || Token::Match(tok, "[;{}] return {"))
tok = tok->linkAt(2);
// C++11 initialize set in initializer list : [,:] std::set<int>{1} [{,]
else if (Token::simpleMatch(tok,"> {") && tok->link())
tok = tok->next()->link();
else if (Token::Match(tok, "[;{}] %str%|%num%")) {
// No warning if numeric constant is followed by a "." or ","

View File

@ -244,6 +244,11 @@ private:
" };\n"
"}");
ASSERT_EQUALS("", errout.str());
check("struct s foo() {\n"
" return (struct s){0};\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void cast() {