[PATCH] D113154: [OpenMP] Add parsing/sema/serialization for 'bind' clause

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 4 05:27:45 PDT 2021


ABataev added inline comments.


================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:4706-4713
+    // OpenMP 5.1 [2.11.7, loop Construct, Restrictions]
+    // If a loop construct is not nested inside another OpenMP construct and it
+    // appears in a procedure, the bind clause must be present.
+    if (CurrentRegion == OMPD_loop && ParentRegion == OMPD_unknown &&
+        BindKind == OMPC_BIND_unknown) {
+      SemaRef.Diag(StartLoc, diag::err_omp_loop_directive_without_bind);
+      return true;
----------------
Do we allow something like this:
```
void foo() {
  #pragma omp loop // no bind
  ...
}
volid bar() {
  #pragma omp parallel
  foo();
}
```
?


================
Comment at: clang/lib/Serialization/ASTReader.cpp:12960
+void OMPClauseReader::VisitOMPBindClause(OMPBindClause *C) {
+  C->setBindKind(static_cast<OpenMPBindClauseKind>(Record.readInt()));
+  C->setLParenLoc(Record.readSourceLocation());
----------------
Use `C->setBindKind(Record.readEnum<OpenMPBindClauseKind>());`


================
Comment at: clang/lib/Serialization/ASTWriter.cpp:6725
+void OMPClauseWriter::VisitOMPBindClause(OMPBindClause *C) {
+  Record.push_back(unsigned(C->getBindKind()));
+  Record.AddSourceLocation(C->getLParenLoc());
----------------
Use `Record.writeEnum(C->getBindKind());`


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

https://reviews.llvm.org/D113154



More information about the llvm-commits mailing list