diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index 26815be03..e0da4f566 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -781,7 +781,8 @@ void CheckCondition::clarifyCondition() // This might be a template if (!isC && tok2->link()) break; - + if (Token::simpleMatch(tok2->astParent(), "?")) + break; clarifyConditionError(tok, tok->strAt(2) == "=", false); break; } else if (!tok2->isName() && !tok2->isNumber() && tok2->str() != ".") diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 037ff6fbd..1faebd50d 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -1213,6 +1213,10 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + check("void f() {\n" + " if (x = b < 0 ? 1 : 2) {}\n" // don't simplify and verify this code + "}", false); + ASSERT_EQUALS("", errout.str()); } // clarify conditions with bitwise operator and comparison