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

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


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

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.


>From 9f4b31288f7766cf37ef9da7d72793a4b9672dc3 Mon Sep 17 00:00:00 2001
From: David Truby <david.truby at arm.com>
Date: Tue, 18 Jun 2024 11:10:43 +0000
Subject: [PATCH] [flang] Change vector always errors to warnings

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.
---
 flang/lib/Lower/Bridge.cpp                      | 3 ---
 flang/lib/Semantics/canonicalize-directives.cpp | 2 +-
 flang/test/Semantics/loop-directives.f90        | 8 ++++----
 3 files changed, 5 insertions(+), 8 deletions(-)

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



More information about the flang-commits mailing list