diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -9024,9 +9024,12 @@ def ext_omp_loop_not_canonical_init : ExtWarn< "initialization clause of OpenMP for loop is not in canonical form " "('var = init' or 'T var = init')">, InGroup; -def err_omp_loop_not_canonical_cond : Error< +def err_omp_before_50_loop_not_canonical_cond : Error< "condition of OpenMP for loop must be a relational comparison " - "('<', '<=', '>', or '>=') of loop variable %0">; + "('<', '<=', '>', or '>=') of loop variable %0">; +def err_omp_after_50_loop_not_canonical_cond : Error< + "condition of OpenMP for loop must be a relational comparison " + "('<', '<=', '>', '>=', or '!=') of loop variable %0">; def err_omp_loop_not_canonical_incr : Error< "increment clause of OpenMP for loop must perform simple addition " "or subtraction on loop variable %0">; diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -5413,12 +5413,15 @@ bool OpenMPIterationSpaceChecker::checkAndSetCond(Expr *S) { // Check test-expr for canonical form, save upper-bound UB, flags for // less/greater and for strict/non-strict comparison. - // OpenMP [2.6] Canonical loop form. Test-expr may be one of the following: + // OpenMP [2.9] Canonical loop form. Test-expr may be one of the following: // var relational-op b // b relational-op var // if (!S) { - SemaRef.Diag(DefaultLoc, diag::err_omp_loop_not_canonical_cond) << LCDecl; + if (SemaRef.getLangOpts().OpenMP < 50) + SemaRef.Diag(DefaultLoc, diag::err_omp_before_50_loop_not_canonical_cond) << LCDecl; + else + SemaRef.Diag(DefaultLoc, diag::err_omp_after_50_loop_not_canonical_cond) << LCDecl; return true; } Condition = S; @@ -5474,8 +5477,12 @@ } if (dependent() || SemaRef.CurContext->isDependentContext()) return false; - SemaRef.Diag(CondLoc, diag::err_omp_loop_not_canonical_cond) - << S->getSourceRange() << LCDecl; + if (SemaRef.getLangOpts().OpenMP < 50) + SemaRef.Diag(CondLoc, diag::err_omp_before_50_loop_not_canonical_cond) + << S->getSourceRange() << LCDecl; + else + SemaRef.Diag(CondLoc, diag::err_omp_after_50_loop_not_canonical_cond) + << S->getSourceRange() << LCDecl; return true; }