Fix FP constStatement with comma operator (#3978)
* Fix FP constStatement with comma operator * Format
This commit is contained in:
parent
64a7ba3c4c
commit
b73aeeda0e
|
@ -1792,11 +1792,11 @@ static bool isConstStatement(const Token *tok, bool cpp)
|
|||
if (tok->astParent()) // warn about const statement on rhs at the top level
|
||||
return isConstStatement(tok->astOperand1(), cpp) && isConstStatement(tok->astOperand2(), cpp);
|
||||
else {
|
||||
const Token* lml = previousBeforeAstLeftmostLeaf(tok);
|
||||
const Token* lml = previousBeforeAstLeftmostLeaf(tok); // don't warn about matrix/vector assignment (e.g. Eigen)
|
||||
if (lml)
|
||||
lml = lml->next();
|
||||
const Token* stream = lml;
|
||||
while (stream && Token::Match(stream->astParent(), ".|[|("))
|
||||
while (stream && Token::Match(stream->astParent(), ".|[|(|*"))
|
||||
stream = stream->astParent();
|
||||
return (!stream || !isLikelyStream(cpp, stream)) && isConstStatement(tok->astOperand2(), cpp);
|
||||
}
|
||||
|
|
|
@ -396,6 +396,16 @@ private:
|
|||
" a.b[4][3].c()->d << x , y, z;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct V {\n"
|
||||
" Eigen::Vector3d& operator[](int i) { return v[i]; }\n"
|
||||
" void f(int a, int b, int c);\n"
|
||||
" Eigen::Vector3d v[1];\n"
|
||||
"};\n"
|
||||
"void V::f(int a, int b, int c) {\n"
|
||||
" (*this)[0] << a, b, c;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// #8451
|
||||
|
|
Loading…
Reference in New Issue