[flang-commits] [flang] [flang][OpenMP] Skip implicit typing for DeclareSimdConstruct (PR #142415)
via flang-commits
flang-commits at lists.llvm.org
Mon Jun 2 08:44:44 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-openmp
Author: Kajetan Puchalski (mrkajetanp)
<details>
<summary>Changes</summary>
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 #<!-- -->140754.
---
Full diff: https://github.com/llvm/llvm-project/pull/142415.diff
2 Files Affected:
- (modified) flang/lib/Semantics/resolve-names.cpp (+1)
- (added) flang/test/Semantics/OpenMP/declare-simd-linear.f90 (+18)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/142415
More information about the flang-commits
mailing list