| 3792 | } |
| 3793 | |
| 3794 | static bool checkEvaluationOrderC(const Token * tok, const Token * tok2, const Token * parent, const Settings & settings, bool & selfAssignmentError) |
| 3795 | { |
| 3796 | // self assignment.. |
| 3797 | if (tok2 == tok && tok->str() == "=" && parent->str() == "=" && isSameExpression(false, tok->astOperand1(), parent->astOperand1(), settings, true, false)) { |
| 3798 | if (settings.severity.isEnabled(Severity::warning) && isSameExpression(true, tok->astOperand1(), parent->astOperand1(), settings, true, false)) |
| 3799 | selfAssignmentError = true; |
| 3800 | return false; |
| 3801 | } |
| 3802 | // Is expression used? |
| 3803 | bool foundError = false; |
| 3804 | visitAstNodes((parent->astOperand1() != tok2) ? parent->astOperand1() : parent->astOperand2(), [&](const Token *tok3) { |
| 3805 | if (tok3->str() == "&" && !tok3->astOperand2()) |
| 3806 | return ChildrenToVisit::none; // don't handle address-of for now |
| 3807 | if (tok3->str() == "(" && Token::simpleMatch(tok3->previous(), "sizeof")) |
| 3808 | return ChildrenToVisit::none; // don't care about sizeof usage |
| 3809 | if (isSameExpression(false, tok->astOperand1(), tok3, settings, true, false)) |
| 3810 | foundError = true; |
| 3811 | return foundError ? ChildrenToVisit::done : ChildrenToVisit::op1_and_op2; |
| 3812 | }); |
| 3813 | |
| 3814 | return foundError; |
| 3815 | } |
| 3816 | |
| 3817 | static bool checkEvaluationOrderCpp11(const Token * tok, const Token * tok2, const Token * parent, const Settings & settings) |
| 3818 | { |
no test coverage detected