[PATCH] D86051: [flang]Add Semantic Checks for OpenMP Allocate Clause

Kiran Chandramohan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 4 00:22:21 PDT 2020


kiranchandramohan accepted this revision.
kiranchandramohan added a comment.
This revision is now accepted and ready to land.

Looking good. Few minor comments. Please wait for one more approval.



================
Comment at: flang/lib/Semantics/resolve-directives.cpp:296
 
+  std::set<const parser::Name *> allocateNames_; // on one directive
+  SymbolSet privateDataSharingAttributeObjects_; // on one directive
----------------
Thinking about this again, this set will probably not work since different occurrences of names have different pointers. And we probably want to flag error at each occurrence of the same variable. So we can very well have a vector/smallvector. Add a test

```
  integer ::  N = 2
  integer :: x

  !ERROR: The ALLOCATE clause requires that 'x' must be listed in a private data-sharing attribute clause on the same directive
  !$omp parallel allocate(omp_default_mem_space : x) allocate(omp_default_mem_space : x)
  do i = 1, N
     x = 2
  enddo
  !$omp end parallel

end
```


================
Comment at: flang/lib/Semantics/resolve-directives.cpp:680
+    bool hasPrivate;
+    for (auto allocName : allocateNames_) {
+      hasPrivate = false;
----------------
Check the clang-tidy warning here.


================
Comment at: flang/lib/Semantics/resolve-directives.cpp:684
+        const Symbol &symbolPrivate{*privateObj};
+        if (allocName->ToString() == symbolPrivate.name().ToString()) {
+          hasPrivate = true;
----------------
I think the ToString() is not required here.
if (allocName->source == symbolPrivate.name())


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86051



More information about the llvm-commits mailing list