-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[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
Conversation
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.
@llvm/pr-subscribers-flang-fir-hlfir @llvm/pr-subscribers-flang-semantics Author: David Truby (DavidTruby) ChangesThis patch changes the error when !dir$ vector always doesn't appear before a Currently no warning is issued when the directive appears in the middle of the Full diff: https://github.com/llvm/llvm-project/pull/95908.diff 3 Files Affected:
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
|
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. |
There was a problem hiding this 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.
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