Fix issue 9352: FP constParameter and constVariable for auto& in combination with ternary ?: operator (#2173)
This commit is contained in:
parent
a4ca6dfee7
commit
068b0b246c
|
@ -1100,6 +1100,9 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings *settings,
|
|||
(Token::simpleMatch(tok2->astParent(), "[") && tok2 == tok2->astParent()->astOperand1()))
|
||||
tok2 = tok2->astParent();
|
||||
|
||||
while (Token::simpleMatch(tok2->astParent(), "?") || (Token::simpleMatch(tok2->astParent(), ":") && Token::simpleMatch(tok2->astParent()->astParent(), "?")))
|
||||
tok2 = tok2->astParent();
|
||||
|
||||
if (Token::Match(tok2->astParent(), "++|--"))
|
||||
return true;
|
||||
|
||||
|
|
|
@ -1906,6 +1906,13 @@ private:
|
|||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(bool b, int& x, int& y) {\n"
|
||||
" auto& z = x;\n"
|
||||
" auto& w = b ? y : z;\n"
|
||||
" w = 1;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void e();\n"
|
||||
"void g(void);\n"
|
||||
"void h(void);\n"
|
||||
|
|
Loading…
Reference in New Issue