================
@@ -11762,52 +11762,98 @@ bool 
OpenMPAtomicCompareChecker::checkCondUpdateStmt(IfStmt *S,
 
   X = BO->getLHS();
 
-  auto *Cond = dyn_cast<BinaryOperator>(S->getCond());
-  if (!Cond) {
-    ErrorInfo.Error = ErrorTy::NotABinaryOp;
-    ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = S->getCond()->getExprLoc();
-    ErrorInfo.ErrorRange = ErrorInfo.NoteRange = 
S->getCond()->getSourceRange();
-    return false;
-  }
-
-  switch (Cond->getOpcode()) {
-  case BO_EQ: {
-    C = Cond;
-    D = BO->getRHS();
-    if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getLHS())) {
-      E = Cond->getRHS();
-    } else if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getRHS())) {
-      E = Cond->getLHS();
-    } else {
-      ErrorInfo.Error = ErrorTy::InvalidComparison;
+  if (auto *Cond = dyn_cast<BinaryOperator>(S->getCond())) {
+    switch (Cond->getOpcode()) {
+    case BO_EQ: {
+      C = Cond;
+      D = BO->getRHS();
+      if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getLHS())) {
+        E = Cond->getRHS();
+      } else if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getRHS())) {
+        E = Cond->getLHS();
+      } else {
+        ErrorInfo.Error = ErrorTy::InvalidComparison;
+        ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
+        ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
+        return false;
+      }
+      break;
+    }
+    case BO_LT:
+    case BO_GT: {
+      E = BO->getRHS();
+      if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getLHS()) &&
+          checkIfTwoExprsAreSame(ContextRef, E, Cond->getRHS())) {
+        C = Cond;
+      } else if (checkIfTwoExprsAreSame(ContextRef, E, Cond->getLHS()) &&
+                 checkIfTwoExprsAreSame(ContextRef, X, Cond->getRHS())) {
+        C = Cond;
+        IsXBinopExpr = false;
+      } else {
+        ErrorInfo.Error = ErrorTy::InvalidComparison;
+        ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
+        ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
+        return false;
+      }
+      break;
+    }
+    default:
+      ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
       ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
       ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
       return false;
     }
-    break;
-  }
-  case BO_LT:
-  case BO_GT: {
-    E = BO->getRHS();
-    if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getLHS()) &&
-        checkIfTwoExprsAreSame(ContextRef, E, Cond->getRHS())) {
-      C = Cond;
-    } else if (checkIfTwoExprsAreSame(ContextRef, E, Cond->getLHS()) &&
-               checkIfTwoExprsAreSame(ContextRef, X, Cond->getRHS())) {
-      C = Cond;
-      IsXBinopExpr = false;
-    } else {
-      ErrorInfo.Error = ErrorTy::InvalidComparison;
-      ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
-      ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
+  } else if (auto *Call = dyn_cast<CXXOperatorCallExpr>(S->getCond())) {
----------------
jhuber6 wrote:

We don't, this will get rejected later when the type is actually instantiated. 
This just prevents it from rejecting the format outright when it isn't even 
used, like in the associated test.

https://github.com/llvm/llvm-project/pull/141142
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to