Fix issue 9352: FP constParameter and constVariable for auto& in combination with ternary ?: operator (#2173)

This commit is contained in:
Paul Fultz II 2019-09-13 01:33:30 -05:00 committed by Daniel Marjamäki
parent a4ca6dfee7
commit 068b0b246c
2 changed files with 10 additions and 0 deletions

View File

@ -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;

View File

@ -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"