diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 036e817c9..812f006dc 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1783,8 +1783,16 @@ static bool isConstStatement(const Token *tok, bool cpp) return isWithoutSideEffects(cpp, tok->astOperand1()) && isConstStatement(tok->astOperand1(), cpp); if (Token::simpleMatch(tok, ".")) return isConstStatement(tok->astOperand2(), cpp); - if (Token::simpleMatch(tok, ",")) // warn about const statement on rhs at the top level - return tok->astParent() ? isConstStatement(tok->astOperand1(), cpp) && isConstStatement(tok->astOperand2(), cpp) : isConstStatement(tok->astOperand2(), cpp); + if (Token::simpleMatch(tok, ",")) { + 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); + if (lml) + lml = lml->next(); + return lml && !isLikelyStream(cpp, lml) && isConstStatement(tok->astOperand2(), cpp); + } + } if (Token::simpleMatch(tok, "?") && Token::simpleMatch(tok->astOperand2(), ":")) // ternary operator return isConstStatement(tok->astOperand1(), cpp) && isConstStatement(tok->astOperand2()->astOperand1(), cpp) && isConstStatement(tok->astOperand2()->astOperand2(), cpp); if (isBracketAccess(tok) && isWithoutSideEffects(cpp, tok->astOperand1(), /*checkArrayAccess*/ true, /*checkReference*/ false)) { diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index 768d7fe99..0e7bdb6bc 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -355,6 +355,12 @@ private: " for(unsigned int a=0, b; a<10; a++ ) {}\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("void f(int a, int b, int c, int d) {\n" + " Eigen::Vector4d V;\n" + " V << a, b, c, d;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } // #8451