forked from OSchip/llvm-project
[Clang][Sema][OpenMP] Fix uninitialized variable Op
This can fix the case atomic_messages
This commit is contained in:
parent
254ee89c7a
commit
b8ec430de7
|
@ -11063,8 +11063,18 @@ bool OpenMPAtomicCompareChecker::checkCondUpdateStmt(IfStmt *S,
|
|||
ErrorInfo.ErrorRange = ErrorInfo.NoteRange = S->getCond()->getSourceRange();
|
||||
return false;
|
||||
}
|
||||
if (Cond->getOpcode() != BO_EQ && Cond->getOpcode() != BO_LT &&
|
||||
Cond->getOpcode() != BO_GT) {
|
||||
|
||||
switch (Cond->getOpcode()) {
|
||||
case BO_EQ:
|
||||
Op = OMPAtomicCompareOp::EQ;
|
||||
break;
|
||||
case BO_LT:
|
||||
Op = OMPAtomicCompareOp::MIN;
|
||||
break;
|
||||
case BO_GT:
|
||||
Op = OMPAtomicCompareOp::MAX;
|
||||
break;
|
||||
default:
|
||||
ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
|
||||
ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
|
||||
ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
|
||||
|
@ -11148,8 +11158,17 @@ bool OpenMPAtomicCompareChecker::checkCondExprStmt(Stmt *S,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (Cond->getOpcode() != BO_EQ && Cond->getOpcode() != BO_LT &&
|
||||
Cond->getOpcode() != BO_GT) {
|
||||
switch (Cond->getOpcode()) {
|
||||
case BO_EQ:
|
||||
Op = OMPAtomicCompareOp::EQ;
|
||||
break;
|
||||
case BO_LT:
|
||||
Op = OMPAtomicCompareOp::MIN;
|
||||
break;
|
||||
case BO_GT:
|
||||
Op = OMPAtomicCompareOp::MAX;
|
||||
break;
|
||||
default:
|
||||
ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
|
||||
ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
|
||||
ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
|
||||
|
|
Loading…
Reference in New Issue