[flang-commits] [flang] aef6b15 - [flang] Allow a construct entity as a concurrent-header index

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Thu Aug 25 14:59:55 PDT 2022


Author: Peter Klausler
Date: 2022-08-25T14:55:22-07:00
New Revision: aef6b15744f7a204fb04903a2b7d08f9dda14a8c

URL: https://github.com/llvm/llvm-project/commit/aef6b15744f7a204fb04903a2b7d08f9dda14a8c
DIFF: https://github.com/llvm/llvm-project/commit/aef6b15744f7a204fb04903a2b7d08f9dda14a8c.diff

LOG: [flang] Allow a construct entity as a concurrent-header index

A construct entity of an ASSOCIATE or SELECT TYPE construct
should be acceptable as an index variable of a concurrent-header in
a FORALL or DO CONCURRENT, so long as it also satisfies other
requirements.

Differential Revision: https://reviews.llvm.org/D132681

Added: 
    

Modified: 
    flang/lib/Semantics/resolve-names.cpp
    flang/test/Semantics/forall01.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index b6185e2517d68..56a8b7f3d6ede 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -5883,10 +5883,10 @@ void ConstructVisitor::ResolveIndexName(
   } else if (!prev) {
     ApplyImplicitRules(symbol);
   } else {
-    const Symbol &prevRoot{ResolveAssociations(*prev)};
+    const Symbol &prevRoot{prev->GetUltimate()};
     // prev could be host- use- or construct-associated with another symbol
     if (!prevRoot.has<ObjectEntityDetails>() &&
-        !prevRoot.has<EntityDetails>()) {
+        !prevRoot.has<AssocEntityDetails>()) {
       Say2(name, "Index name '%s' conflicts with existing identifier"_err_en_US,
           *prev, "Previous declaration of '%s'"_en_US);
       context().SetError(symbol);

diff  --git a/flang/test/Semantics/forall01.f90 b/flang/test/Semantics/forall01.f90
index 39d2a5c8bd2f4..d90e5291a84b4 100644
--- a/flang/test/Semantics/forall01.f90
+++ b/flang/test/Semantics/forall01.f90
@@ -110,3 +110,25 @@ subroutine forall6
     a(1)%p => b(i)
   end forall
 end
+
+subroutine forall7(x)
+  integer :: iarr(1)
+  real :: a(10)
+  class(*) :: x
+  associate (j => iarr(1))
+    forall (j=1:size(a))
+      a(j) = a(j) + 1
+    end forall
+  end associate
+  associate (j => iarr(1) + 1)
+    forall (j=1:size(a))
+      a(j) = a(j) + 1
+    end forall
+  end associate
+  select type (j => x)
+  type is (integer)
+    forall (j=1:size(a))
+      a(j) = a(j) + 1
+    end forall
+  end select
+end subroutine


        


More information about the flang-commits mailing list