[PATCH] D66903: [OPENMP] Update the diagnosis message for canonical loop form

Chi Chun Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 28 13:16:12 PDT 2019


cchen created this revision.
Herald added subscribers: cfe-commits, guansong.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

The previous patch (https://reviews.llvm.org/D54441) support the
relational-op != very well for openmp canonical loop form, however,
it didn't update the diagnosis message. So this patch is simply
update the diagnosis message by adding != for OpenMP 5.0.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66903

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaOpenMP.cpp


Index: clang/lib/Sema/SemaOpenMP.cpp
===================================================================
--- clang/lib/Sema/SemaOpenMP.cpp
+++ 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;
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ 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<OpenMPLoopForm>;
-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">;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66903.217708.patch
Type: text/x-patch
Size: 2531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190828/989d66d7/attachment-0001.bin>


More information about the cfe-commits mailing list