Skip to content

[flang] Change vector always errors to warnings #95908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

DavidTruby
Copy link
Member

@DavidTruby DavidTruby commented Jun 18, 2024

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.

Fixes #95780

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.
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir flang:semantics labels Jun 18, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 18, 2024

@llvm/pr-subscribers-flang-fir-hlfir

@llvm/pr-subscribers-flang-semantics

Author: David Truby (DavidTruby)

Changes

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 --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

@DavidTruby
Copy link
Member Author

I couldn't work out how to fix the second part of the issue @psteinfeld is seeing where the message isn't printed in the specification part. In order to get a fix up faster I think it's fine for now to just allow this through without a warning and add the warning later. When the directive appears in the execution part a warning is printed as expected.

Copy link
Contributor

@psteinfeld psteinfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

All builds and tests correctly and looks good.

@DavidTruby DavidTruby merged commit 506b4cd into llvm:main Jun 18, 2024
9 of 10 checks passed
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problems with the VECTOR ALWAYS directive
3 participants