Fixed #8190 (False positive constStatement - return (struct media_frames_per_second) {0};)
This commit is contained in:
parent
89b9f57759
commit
411c5e5f7e
|
@ -1571,20 +1571,13 @@ void CheckOther::checkIncompleteStatement()
|
||||||
if (Token::Match(tok, "(|["))
|
if (Token::Match(tok, "(|["))
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
|
|
||||||
else if (Token::simpleMatch(tok, "= {"))
|
else if (tok->str() == "{" && tok->astParent())
|
||||||
tok = tok->next()->link();
|
tok = tok->link();
|
||||||
|
|
||||||
// C++11 struct/array/etc initialization in initializer list
|
// C++11 struct/array/etc initialization in initializer list
|
||||||
else if (Token::Match(tok->previous(), "%name%|] {") && !Token::findsimplematch(tok,";",tok->link()))
|
else if (Token::Match(tok->previous(), "%name%|] {") && !Token::findsimplematch(tok,";",tok->link()))
|
||||||
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%")) {
|
else if (Token::Match(tok, "[;{}] %str%|%num%")) {
|
||||||
// No warning if numeric constant is followed by a "." or ","
|
// No warning if numeric constant is followed by a "." or ","
|
||||||
|
|
|
@ -244,6 +244,11 @@ private:
|
||||||
" };\n"
|
" };\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("struct s foo() {\n"
|
||||||
|
" return (struct s){0};\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void cast() {
|
void cast() {
|
||||||
|
|
Loading…
Reference in New Issue