[flang-commits] [flang] [flang][OpenMP] Resolve names for declare simd uniform clause (PR #142160)

via flang-commits flang-commits at lists.llvm.org
Fri May 30 07:34:49 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-openmp

Author: Kajetan Puchalski (mrkajetanp)

<details>
<summary>Changes</summary>

Add a visitor for OmpClause::Uniform to resolve its parameter names.
Fixes issue #<!-- -->140741.

---
Full diff: https://github.com/llvm/llvm-project/pull/142160.diff


4 Files Affected:

- (modified) flang/include/flang/Semantics/symbol.h (+1-1) 
- (modified) flang/lib/Semantics/resolve-directives.cpp (+7) 
- (modified) flang/lib/Semantics/resolve-names.cpp (+5) 
- (added) flang/test/Semantics/OpenMP/declare-simd-uniform.f90 (+13) 


``````````diff
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index 4cded64d170cd..9ebdd3a8081ed 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -786,7 +786,7 @@ class Symbol {
       OmpExecutableAllocateDirective, OmpDeclareSimd, OmpDeclareTarget,
       OmpThreadprivate, OmpDeclareReduction, OmpFlushed, OmpCriticalLock,
       OmpIfSpecified, OmpNone, OmpPreDetermined, OmpImplicit, OmpDependObject,
-      OmpInclusiveScan, OmpExclusiveScan, OmpInScanReduction);
+      OmpInclusiveScan, OmpExclusiveScan, OmpInScanReduction, OmpUniform);
   using Flags = common::EnumSet<Flag, Flag_enumSize>;
 
   const Scope &owner() const { return *owner_; }
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 9fa7bc8964854..ecb4f02732a4b 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -550,6 +550,13 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
     return false;
   }
 
+  bool Pre(const parser::OmpClause::Uniform &x) {
+    for (const auto &name : x.v) {
+      ResolveOmpName(name, Symbol::Flag::OmpUniform);
+    }
+    return false;
+  }
+
   bool Pre(const parser::OmpInReductionClause &x) {
     auto &objects{std::get<parser::OmpObjectList>(x.t)};
     ResolveOmpObjectList(objects, Symbol::Flag::OmpInReduction);
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 57035c57ee16f..7bea6fdb00e55 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1511,6 +1511,11 @@ class OmpVisitor : public virtual DeclarationVisitor {
     return false;
   }
 
+  bool Pre(const parser::OpenMPDeclareSimdConstruct &x) {
+    AddOmpSourceRange(x.source);
+    return true;
+  }
+
   bool Pre(const parser::OmpInitializerProc &x) {
     auto &procDes = std::get<parser::ProcedureDesignator>(x.t);
     auto &name = std::get<parser::Name>(procDes.u);
diff --git a/flang/test/Semantics/OpenMP/declare-simd-uniform.f90 b/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
new file mode 100644
index 0000000000000..3a0c52b8e7b0e
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
@@ -0,0 +1,13 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+! Test declare simd with uniform clause
+
+function add2(a,b,i,fact,alc) result(c)
+  !$omp declare simd(add2) uniform(a,b,fact)
+  integer :: i
+  integer,pointer::alc
+  double precision :: a(*),b(*),fact,c
+  c = a(i) + b(i) + fact
+end function
+
+end
+

``````````

</details>


https://github.com/llvm/llvm-project/pull/142160


More information about the flang-commits mailing list