[Flang][OpenMP] Add source range for a few directives
authorKiran Chandramohan <kiran.chandramohan@arm.com>
Wed, 5 Jul 2023 12:57:27 +0000 (12:57 +0000)
committerKiran Chandramohan <kiran.chandramohan@arm.com>
Wed, 5 Jul 2023 13:27:52 +0000 (13:27 +0000)
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

flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/OpenMP/barrier.f90 [new file with mode: 0644]
flang/test/Semantics/OpenMP/requires.f90 [new file with mode: 0644]
flang/test/Semantics/OpenMP/taskwait.f90 [new file with mode: 0644]

index 78b07f0..f6b1759 100644 (file)
@@ -1375,6 +1375,14 @@ public:
 
   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 (file)
index 0000000..1483fbd
--- /dev/null
@@ -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 (file)
index 0000000..e2093ec
--- /dev/null
@@ -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 (file)
index 0000000..e60051c
--- /dev/null
@@ -0,0 +1,4 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+
+!$omp taskwait
+end