[flang-commits] [flang] [flang] Change vector always errors to warnings (PR #95908)

via flang-commits flang-commits at lists.llvm.org
Tue Jun 18 04:14:55 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: David Truby (DavidTruby)

<details>
<summary>Changes</summary>

This patch changes the error when !dir$ vector always doesn't appear before a
loop into a warning. It also removes the error while lowering when the vector
always directive has appeared, simply ignoring the directive instead.

Currently no warning is issued when the directive appears in the middle of the
specification part. This should be added in a future patch.


---
Full diff: https://github.com/llvm/llvm-project/pull/95908.diff


3 Files Affected:

- (modified) flang/lib/Lower/Bridge.cpp (-3) 
- (modified) flang/lib/Semantics/canonicalize-directives.cpp (+1-1) 
- (modified) flang/test/Semantics/loop-directives.f90 (+4-4) 


``````````diff
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index c73d43210a260..05a2f391f7094 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -2607,9 +2607,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
 
     if (e->isA<Fortran::parser::NonLabelDoStmt>())
       e->dirs.push_back(&dir);
-    else
-      fir::emitFatalError(toLocation(),
-                          "loop directive must appear before a loop");
   }
 
   void genFIR(const Fortran::parser::CompilerDirective &dir) {
diff --git a/flang/lib/Semantics/canonicalize-directives.cpp b/flang/lib/Semantics/canonicalize-directives.cpp
index 4bf36754eb10b..ae691ab612ba2 100644
--- a/flang/lib/Semantics/canonicalize-directives.cpp
+++ b/flang/lib/Semantics/canonicalize-directives.cpp
@@ -104,7 +104,7 @@ void CanonicalizationOfDirectives::CheckLoopDirective(
     std::string s{parser::ToUpperCaseLetters(dir.source.ToString())};
     s.pop_back(); // Remove trailing newline from source string
     messages_.Say(
-        dir.source, "A DO loop must follow the %s directive"_err_en_US, s);
+        dir.source, "A DO loop must follow the %s directive"_warn_en_US, s);
   }
 }
 
diff --git a/flang/test/Semantics/loop-directives.f90 b/flang/test/Semantics/loop-directives.f90
index e2807c1f9d0e2..6f994c767d45f 100644
--- a/flang/test/Semantics/loop-directives.f90
+++ b/flang/test/Semantics/loop-directives.f90
@@ -1,19 +1,19 @@
-! RUN: %python %S/test_errors.py %s %flang
+! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror
 
 subroutine empty
-  ! ERROR: A DO loop must follow the VECTOR ALWAYS directive
+  ! WARNING: A DO loop must follow the VECTOR ALWAYS directive
   !dir$ vector always
 end subroutine empty
 
 subroutine non_do
-  ! ERROR: A DO loop must follow the VECTOR ALWAYS directive
+  ! WARNING: A DO loop must follow the VECTOR ALWAYS directive
   !dir$ vector always
   a = 1
 end subroutine non_do
 
 subroutine execution_part
   do i=1,10
-  ! ERROR: A DO loop must follow the VECTOR ALWAYS directive
+  ! WARNING: A DO loop must follow the VECTOR ALWAYS directive
   !dir$ vector always
   end do
 end subroutine execution_part

``````````

</details>


https://github.com/llvm/llvm-project/pull/95908


More information about the flang-commits mailing list