-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[flang][OpenMP] Skip implicit typing for OpenMPDeclarativeConstruct #142415
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
[flang][OpenMP] Skip implicit typing for OpenMPDeclarativeConstruct #142415
Conversation
@llvm/pr-subscribers-flang-semantics Author: Kajetan Puchalski (mrkajetanp) ChangesDeclareSimdConstruct currently can implicitly declare variables regardless of whether the source code contains "implicit none" or not. This causes semantic analysis issues if the implicit type does not match the declared type. To solve it, skip implicit typing for declare simd. Fixes issue #140754. Full diff: https://github.com/llvm/llvm-project/pull/142415.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 7bea6fdb00e55..93096442329e9 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1513,6 +1513,7 @@ class OmpVisitor : public virtual DeclarationVisitor {
bool Pre(const parser::OpenMPDeclareSimdConstruct &x) {
AddOmpSourceRange(x.source);
+ SkipImplicitTyping(true);
return true;
}
diff --git a/flang/test/Semantics/OpenMP/declare-simd-linear.f90 b/flang/test/Semantics/OpenMP/declare-simd-linear.f90
new file mode 100644
index 0000000000000..681cac7f02e0f
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/declare-simd-linear.f90
@@ -0,0 +1,18 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+! Test declare simd with linear clause
+
+module mod
+contains
+subroutine sub(m,i)
+!$omp declare simd linear(i:1)
+ implicit none
+ integer*8 i,n
+ value i
+ parameter(n=10000)
+ real*4 a,b,m
+ common/com1/a(n)
+ common/com2/b(n)
+ a(i) = b(i) + m
+ i=i+2
+end subroutine
+end module
|
@llvm/pr-subscribers-flang-openmp Author: Kajetan Puchalski (mrkajetanp) ChangesDeclareSimdConstruct currently can implicitly declare variables regardless of whether the source code contains "implicit none" or not. This causes semantic analysis issues if the implicit type does not match the declared type. To solve it, skip implicit typing for declare simd. Fixes issue #140754. Full diff: https://github.com/llvm/llvm-project/pull/142415.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 7bea6fdb00e55..93096442329e9 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1513,6 +1513,7 @@ class OmpVisitor : public virtual DeclarationVisitor {
bool Pre(const parser::OpenMPDeclareSimdConstruct &x) {
AddOmpSourceRange(x.source);
+ SkipImplicitTyping(true);
return true;
}
diff --git a/flang/test/Semantics/OpenMP/declare-simd-linear.f90 b/flang/test/Semantics/OpenMP/declare-simd-linear.f90
new file mode 100644
index 0000000000000..681cac7f02e0f
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/declare-simd-linear.f90
@@ -0,0 +1,18 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+! Test declare simd with linear clause
+
+module mod
+contains
+subroutine sub(m,i)
+!$omp declare simd linear(i:1)
+ implicit none
+ integer*8 i,n
+ value i
+ parameter(n=10000)
+ real*4 a,b,m
+ common/com1/a(n)
+ common/com2/b(n)
+ a(i) = b(i) + m
+ i=i+2
+end subroutine
+end module
|
This is potentially applicable to all declarative directives. Would it make sense to add
For
|
We should try to work out whether this actually is the desired behaviour. Doing this for declare simd causes the test at
|
In this case at least, removal of these expectations is correct. It is OK to handle this more generally in a separate PR. But please consider resetting SkipImplicitType in the |
244e029
to
71925f7
Compare
I this is a spurious CI error? The failing test doesn't have any OpenMP in it, and it works when I run it locally. |
I think this was fixed in #142363. Could you rebase? |
DeclareSimdConstruct currently can implicitly declare variables regardless of whether the source code contains "implicit none" or not. This causes semantic analysis issues if the implicit type does not match the declared type. To solve it, skip implicit typing for declare simd. Fixes issue llvm#140754. Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
71925f7
to
a50ca71
Compare
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.
LGTM. Please wait for @tblah.
In a separate patch we might be able to remove SkipImplicitTyping(true);
for other declarative constructs as well.
A comment indicating why SkipImplicitTyping
is required might be helpful.
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.
LGTM.
In a separate patch we might be able to remove
SkipImplicitTyping(true);
for other declarative constructs as well.A comment indicating why
SkipImplicitTyping
is required might be helpful.
+1
DeclareSimdConstruct (and other declarative constructs) can currently implicitly declare variables regardless of whether the source code contains "implicit none" or not. This causes semantic analysis issues if the implicit type does not match the declared type. To solve it, skip implicit typing for OpenMPDeclarativeConstruct. Fixes issue #140754.