[flang-commits] [flang] 8acae1a - [Flang][OpenMP] Add source range for a few directives

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Wed Jul 5 06:28:08 PDT 2023


Author: Kiran Chandramohan
Date: 2023-07-05T13:27:52Z
New Revision: 8acae1a88bb5210d0eb6180b50a0c21c3e90b524

URL: https://github.com/llvm/llvm-project/commit/8acae1a88bb5210d0eb6180b50a0c21c3e90b524
DIFF: https://github.com/llvm/llvm-project/commit/8acae1a88bb5210d0eb6180b50a0c21c3e90b524.diff

LOG: [Flang][OpenMP] Add source range for a few directives

The sourcerange was missing for a few directives when
they were the first directive to appear in a program
without a program statement.

Reviewed By: DavidTruby

Differential Revision: https://reviews.llvm.org/D153634

Added: 
    flang/test/Semantics/OpenMP/barrier.f90
    flang/test/Semantics/OpenMP/requires.f90
    flang/test/Semantics/OpenMP/taskwait.f90

Modified: 
    flang/lib/Semantics/resolve-names.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 78b07f098cd57a..f6b17598e4af3f 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1375,6 +1375,14 @@ class OmpVisitor : public virtual DeclarationVisitor {
 
   static bool NeedsScope(const parser::OpenMPBlockConstruct &);
 
+  bool Pre(const parser::OpenMPRequiresConstruct &x) {
+    AddOmpSourceRange(x.source);
+    return true;
+  }
+  bool Pre(const parser::OmpSimpleStandaloneDirective &x) {
+    AddOmpSourceRange(x.source);
+    return true;
+  }
   bool Pre(const parser::OpenMPBlockConstruct &);
   void Post(const parser::OpenMPBlockConstruct &);
   bool Pre(const parser::OmpBeginBlockDirective &x) {

diff  --git a/flang/test/Semantics/OpenMP/barrier.f90 b/flang/test/Semantics/OpenMP/barrier.f90
new file mode 100644
index 00000000000000..1483fbd08f9585
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/barrier.f90
@@ -0,0 +1,4 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+
+!$omp barrier
+end

diff  --git a/flang/test/Semantics/OpenMP/requires.f90 b/flang/test/Semantics/OpenMP/requires.f90
new file mode 100644
index 00000000000000..e2093ec5032664
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/requires.f90
@@ -0,0 +1,4 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+
+!$omp requires reverse_offload
+end

diff  --git a/flang/test/Semantics/OpenMP/taskwait.f90 b/flang/test/Semantics/OpenMP/taskwait.f90
new file mode 100644
index 00000000000000..e60051c9da8acb
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/taskwait.f90
@@ -0,0 +1,4 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+
+!$omp taskwait
+end


        


More information about the flang-commits mailing list