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

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 28 13:27:58 PDT 2019


ABataev added a comment.

What about the check for `!=`? it would be good to allow it only for OpenMP 5.0.
Also, add/update the tests.



================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9027-9032
+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">;
----------------
You can merge these 2 messages into one using something like 
`"condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', %select{or '>='|'>=', or '!='}0) of loop variable %1"`


================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:5422
+		if (SemaRef.getLangOpts().OpenMP < 50)
+			SemaRef.Diag(DefaultLoc, diag::err_omp_before_50_loop_not_canonical_cond) << LCDecl;
+		else
----------------
If you merge 2 messages into one, you can diagnose it this way:
```
SemaRef.Diag(DefaultLoc, diag::err_omp_loop_not_canonical_cond) << (SemaRef.getLangOpts().OpenMP <= 45 ? 0 : 1) << LCDecl;
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66559/new/

https://reviews.llvm.org/D66559





More information about the cfe-commits mailing list